feat: adjust routes trip-updates-by-* to include the realtime part and the abs count of the trips

This commit is contained in:
dancingCycle 2024-01-11 20:47:56 +01:00
parent 09636ab141
commit 9711c33a2c
2 changed files with 4 additions and 10 deletions

View File

@ -12,15 +12,13 @@ async function get(agencyid = 0, day = '2023-12-27') {
const schema = process.env.DB_SCHEMA || 'schema';
const tomorrow = new Date(day);
//console.log('tomorrow UTC: ' + tomorrow.toUTCString());
tomorrow.setUTCDate(tomorrow.getUTCDate() + 1);
//console.log('tomorrow UTC: ' + tomorrow.toUTCString());
//console.log('tomorrow ISO: ' + tomorrow.toISOString());
//console.log('tomorrow ISO substring: ' + tomorrow.toISOString().substring(0, 10));
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 `
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, count(timestamp_pgsql) filter(WHERE timestamp_pgsql >= '${day}' AND timestamp_pgsql < '`
+ tomorrow.toISOString().substring(0, 10)
+ `') AS rt_part FROM `
+ schema
+ `.vw_join_gncy_rts_trps_srvcs_pdts WHERE dates like '%${day}%' AND agency_id = '${agencyid}' AND ((timestamp_pgsql >= '${day}' AND timestamp_pgsql < '`
+ `.vw_join_gncy_rts_trps_srvcs_pdts WHERE dates like '%${day}%' AND agency_id = '${agencyid}' AND ((timestamp_pgsql >= '${day}' AND timestamp_pgsql < '`
+ tomorrow.toISOString().substring(0, 10)
+ `') OR timestamp_pgsql IS NULL) GROUP BY route_id, route_short_name, agency_id, agency_name ORDER BY timestamp_pgsql, route_short_name ASC;`

View File

@ -12,11 +12,7 @@ async function get(routeid = 0, day = '2023-12-16') {
const schema = process.env.DB_SCHEMA || 'schema';
const tomorrow = new Date(day);
//console.log('tomorrow UTC: ' + tomorrow.toUTCString());
tomorrow.setUTCDate(tomorrow.getUTCDate() + 1);
//console.log('tomorrow UTC: ' + tomorrow.toUTCString());
//console.log('tomorrow ISO: ' + tomorrow.toISOString());
//console.log('tomorrow ISO substring: ' + tomorrow.toISOString().substring(0, 10));
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