|
|
|
@ -1,10 +1,14 @@ |
|
|
|
// DEBUG... COMENTAR DEPOIS
|
|
|
|
_log.info('service called...'); |
|
|
|
//_log.info('service called...');
|
|
|
|
|
|
|
|
//const astroType = _req.getString("astroType");
|
|
|
|
//_log.info(astroType)
|
|
|
|
const aroundAstroUid = _req.getString("aroundAstroUid"); |
|
|
|
_log.info("AroundAstroUid: ", aroundAstroUid); |
|
|
|
//_log.info("AroundAstroUid: ", aroundAstroUid);
|
|
|
|
|
|
|
|
//DEBUG - simulate slow server - DONT FORGET TO COMMENT
|
|
|
|
//_log.info("Slow server...");
|
|
|
|
//_exec.sleep(3000);
|
|
|
|
|
|
|
|
/* |
|
|
|
const page = _req.getInt("page", 1); |
|
|
|
@ -26,47 +30,53 @@ if (aroundAstroUid && aroundAstroUid != "") { |
|
|
|
filterParams.add(aroundAstroUid); |
|
|
|
} |
|
|
|
_log.info("Filter params:", filterParams); |
|
|
|
|
|
|
|
*/ |
|
|
|
const dbAstros = _db.query(`
|
|
|
|
SELECT |
|
|
|
astro.uid, |
|
|
|
astro.uid |
|
|
|
--astro.id, |
|
|
|
astro.name |
|
|
|
,astro.name |
|
|
|
,astro_type.name AS "astro_type" |
|
|
|
--,astro_type.id AS "astro_type_code" |
|
|
|
--astro.equatorial_radius, |
|
|
|
--astro.rotation_velocity, |
|
|
|
--,astro.around_astro_id |
|
|
|
--,around.uid as "around_astro_uid" |
|
|
|
--astro.periapsis, |
|
|
|
--astro.apoapsis, |
|
|
|
,astro.periapsis |
|
|
|
,astro.apoapsis |
|
|
|
--astro.image |
|
|
|
FROM astro |
|
|
|
INNER JOIN astro_type |
|
|
|
ON astro.type_id = astro_type.id |
|
|
|
LEFT JOIN ( SELECT id,uid FROM astro ) AS around |
|
|
|
ON astro.around_astro_id = around.id |
|
|
|
LEFT JOIN ( SELECT id,uid,name FROM astro ) AS around |
|
|
|
ON astro.around_astro_id = around.id |
|
|
|
WHERE |
|
|
|
astro.active = TRUE |
|
|
|
AND astro_type.active = TRUE |
|
|
|
AND around.uid = ?::uuid |
|
|
|
`,aroundAstroUid);
|
|
|
|
/* |
|
|
|
${filterWhere} |
|
|
|
--LIMIT 8 |
|
|
|
--OFFSET ${offset} |
|
|
|
`, filterParams);
|
|
|
|
|
|
|
|
*/ |
|
|
|
const astros = _val.list() |
|
|
|
for (const dbAstro of dbAstros) { |
|
|
|
astros.add( |
|
|
|
_val.map() |
|
|
|
.set('id', dbAstro.getString('uid')) |
|
|
|
.set('name', dbAstro.getString('name')) |
|
|
|
.set('type', dbAstro.getString('astro_type')) |
|
|
|
.set('periapsis', dbAstro.getString('periapsis')) |
|
|
|
.set('apoapsis', dbAstro.getString('apoapsis')) |
|
|
|
) |
|
|
|
} |
|
|
|
|
|
|
|
// DEBUG...COMENTAR DEPOIS!
|
|
|
|
//_log.info( 'Server return...', astros );
|
|
|
|
|
|
|
|
_out.json(astros) |
|
|
|
*/ |
|
|
|
_out.json(astros); |
|
|
|
|
|
|
|
// DEBUG...COMENTAR DEPOIS!
|
|
|
|
_log.info('service ended!'); |