// DEBUG... COMENTAR DEPOIS //_log.info('service called...'); const astroType = _req.getString("astroType"); // DEBUG... COMENTAR DEPOIS //_log.info(astroType) const page = _req.getInt("page", 1); let offset = (page - 1) * 8; if (offset < 0) { offset = 0; } let filterWhere = ""; const filterParams = _val.list() if (astroType != "" && astroType != "all") { filterWhere = " AND astro_type.uid = ?::uuid "; filterParams.add(astroType); } // DEBUG... COMENTAR DEPOIS //_log.info("Filter params:", filterParams); const dbAstros = _db.query(` SELECT astro.uid, --astro.id, 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 --astro.periapsis, --astro.apoapsis, --astro.image FROM astro INNER JOIN astro_type ON astro.type_id = astro_type.id WHERE astro.active = TRUE AND astro_type.active = TRUE ${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')) ) } // DEBUG...COMENTAR DEPOIS! //_log.info( 'Server return...', astros ); _out.json(astros) // DEBUG...COMENTAR DEPOIS! //_log.info('service ended!');