feat: adjust API route trip-updates-by-agency-day and trip-updates-by-route-day

This commit is contained in:
dancingCycle 2023-12-28 08:47:14 +01:00
parent 9870cfc1fb
commit f640f268d2
2 changed files with 3 additions and 2 deletions

View File

@ -11,7 +11,7 @@ async function get(agencyid = 0, day = '2023-12-27') {
const schema = process.env.DB_SCHEMA || 'schema';
const query = `SELECT agency_name, agency_id, route_id, route_short_name, count(service_id) AS service_id, count(trip_id) AS trip_id, count(trip_short_name) AS trip_short_name, count(trip_headsign) AS trip_headsign, max(timestamp_pgsql) AS timestamp_pgsql FROM ` + schema + `.vw_join_gncy_rts_trps_srvcs_pdts WHERE dates like '%${day}%' and agency_id = '${agencyid}' GROUP BY route_id, route_short_name, agency_id, agency_name ORDER BY timestamp_pgsql, route_short_name ASC;`
const query = `SELECT agency_name, agency_id, route_id, route_short_name, count(service_id) AS service_id, count(trip_id) AS trip_id, count(trip_short_name) AS trip_short_name, count(trip_headsign) AS trip_headsign, max(timestamp_pgsql) AS timestamp_pgsql FROM ` + schema + `.vw_join_gncy_rts_trps_srvcs_pdts WHERE dates like '%${day}%' AND agency_id = '${agencyid}' AND (timestamp_pgsql > '${day}' OR timestamp_pgsql IS NULL) GROUP BY route_id, route_short_name, agency_id, agency_name ORDER BY timestamp_pgsql, route_short_name ASC;`
return await db.query(query);
};

View File

@ -12,7 +12,8 @@ async function get(routeid = 0, day = '2023-12-16') {
const schema = process.env.DB_SCHEMA || 'schema';
//TODO Sort by timestamp!
const query = `SELECT agency_name, agency_id, route_id, route_short_name, service_id, trip_id, trip_short_name, trip_headsign, timestamp_pgsql FROM ` + schema + `.vw_join_gncy_rts_trps_srvcs_pdts WHERE dates like '%${day}%' and route_id = '${routeid}' ORDER BY timestamp_pgsql, route_short_name ASC;`
const query = `SELECT agency_name, agency_id, route_id, route_short_name, service_id, trip_id, trip_short_name, trip_headsign, timestamp_pgsql FROM ` + schema + `.vw_join_gncy_rts_trps_srvcs_pdts WHERE dates like '%${day}%' AND route_id = '${routeid}' AND (timestamp_pgsql > '${day}' OR timestamp_pgsql IS NULL) ORDER BY timestamp_pgsql, route_short_name ASC;`
console.log('query: ' + query);
return await db.query(query);
};