@golemio/public-transport 0.1.0-dev.2922113447 → 0.1.0-dev.2927028941
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/db/migrations/postgresql/20261008120000-add-get-feed-departures.js +53 -0
- package/db/migrations/postgresql/sqls/20261008120000-add-get-feed-departures-down.sql +76 -0
- package/db/migrations/postgresql/sqls/20261008120000-add-get-feed-departures-up.sql +236 -0
- package/dist/output-gateway/gtfs/data-access/redis/RunTripsRedisRepository.d.ts +1 -1
- package/dist/output-gateway/gtfs/data-access/redis/RunTripsRedisRepository.js +3 -5
- package/dist/output-gateway/gtfs/data-access/redis/RunTripsRedisRepository.js.map +1 -1
- package/dist/output-gateway/gtfs/domain/repository/IRunTripsRedisRepository.d.ts +1 -1
- package/dist/output-gateway/gtfs/models/GTFSStopTimesModel.d.ts +6 -0
- package/dist/output-gateway/gtfs/models/GTFSStopTimesModel.js +40 -0
- package/dist/output-gateway/gtfs/models/GTFSStopTimesModel.js.map +1 -1
- package/dist/output-gateway/index.d.ts +1 -1
- package/dist/output-gateway/index.js +4 -0
- package/dist/output-gateway/index.js.map +1 -1
- package/dist/output-gateway/pid/controllers/v2/V2DepartureBoardsController.d.ts +5 -0
- package/dist/output-gateway/pid/controllers/v2/V2DepartureBoardsController.js +26 -3
- package/dist/output-gateway/pid/controllers/v2/V2DepartureBoardsController.js.map +1 -1
- package/dist/output-gateway/pid/data-access/DeparturesRepository.js +3 -1
- package/dist/output-gateway/pid/data-access/DeparturesRepository.js.map +1 -1
- package/dist/output-gateway/pid/data-access/interfaces/DepartureInterfaces.d.ts +1 -0
- package/dist/output-gateway/pid/models/PIDDepartureBoardsModel.js +8 -7
- package/dist/output-gateway/pid/models/PIDDepartureBoardsModel.js.map +1 -1
- package/dist/output-gateway/pid/models/interfaces/IGetDeparturesOptions.d.ts +1 -0
- package/dist/output-gateway/public/routers/v1/V1DepartureBoardsRouter.d.ts +16 -0
- package/dist/output-gateway/public/routers/v1/V1DepartureBoardsRouter.js +67 -0
- package/dist/output-gateway/public/routers/v1/V1DepartureBoardsRouter.js.map +1 -0
- package/dist/output-gateway/public/service/helpers/trip-scope/strategy/StopTimesTripScopeHandler.d.ts +3 -0
- package/dist/output-gateway/public/service/helpers/trip-scope/strategy/StopTimesTripScopeHandler.js +14 -7
- package/dist/output-gateway/public/service/helpers/trip-scope/strategy/StopTimesTripScopeHandler.js.map +1 -1
- package/docs/follow-ups.md +11 -5
- package/docs/implementation_documentation.md +12 -0
- package/docs/openapi-output.yaml +65 -2
- package/package.json +1 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var dbm;
|
|
4
|
+
var type;
|
|
5
|
+
var seed;
|
|
6
|
+
var fs = require('fs');
|
|
7
|
+
var path = require('path');
|
|
8
|
+
var Promise;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* We receive the dbmigrate dependency from dbmigrate initially.
|
|
12
|
+
* This enables us to not have to rely on NODE_PATH.
|
|
13
|
+
*/
|
|
14
|
+
exports.setup = function(options, seedLink) {
|
|
15
|
+
dbm = options.dbmigrate;
|
|
16
|
+
type = dbm.dataType;
|
|
17
|
+
seed = seedLink;
|
|
18
|
+
Promise = options.Promise;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
exports.up = function(db) {
|
|
22
|
+
var filePath = path.join(__dirname, 'sqls', '20261008120000-add-get-feed-departures-up.sql');
|
|
23
|
+
return new Promise( function( resolve, reject ) {
|
|
24
|
+
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
|
|
25
|
+
if (err) return reject(err);
|
|
26
|
+
console.log('received data: ' + data);
|
|
27
|
+
|
|
28
|
+
resolve(data);
|
|
29
|
+
});
|
|
30
|
+
})
|
|
31
|
+
.then(function(data) {
|
|
32
|
+
return db.runSql(data);
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
exports.down = function(db) {
|
|
37
|
+
var filePath = path.join(__dirname, 'sqls', '20261008120000-add-get-feed-departures-down.sql');
|
|
38
|
+
return new Promise( function( resolve, reject ) {
|
|
39
|
+
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
|
|
40
|
+
if (err) return reject(err);
|
|
41
|
+
console.log('received data: ' + data);
|
|
42
|
+
|
|
43
|
+
resolve(data);
|
|
44
|
+
});
|
|
45
|
+
})
|
|
46
|
+
.then(function(data) {
|
|
47
|
+
return db.runSql(data);
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
exports._meta = {
|
|
52
|
+
"version": 1
|
|
53
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
DROP FUNCTION public_transport.get_feed_departures(integer, character varying, integer, timestamp with time zone, timestamp with time zone, integer, timestamp with time zone, timestamp with time zone, integer);
|
|
2
|
+
|
|
3
|
+
-- CREATE OR REPLACE VIEW cannot drop a column
|
|
4
|
+
DROP VIEW public_transport.v_vehiclepositions_trip_position_vehicle_info;
|
|
5
|
+
CREATE VIEW public_transport.v_vehiclepositions_trip_position_vehicle_info AS
|
|
6
|
+
SELECT "trip->last_position".delay AS delay_seconds,
|
|
7
|
+
trip.wheelchair_accessible AS real_wheelchair_accessible,
|
|
8
|
+
"trip->last_position".is_canceled,
|
|
9
|
+
trip.agency_name_real AS "trip.agency_name_real",
|
|
10
|
+
trip.agency_name_scheduled AS "trip.agency_name_scheduled",
|
|
11
|
+
trip.cis_line_id AS "trip.cis_line_id",
|
|
12
|
+
trip.cis_line_short_name AS "trip.cis_line_short_name",
|
|
13
|
+
trip.cis_trip_number AS "trip.cis_trip_number",
|
|
14
|
+
trip.gtfs_block_id AS "trip.gtfs_block_id",
|
|
15
|
+
trip.gtfs_route_id AS "trip.gtfs_route_id",
|
|
16
|
+
trip.gtfs_route_short_name AS "trip.gtfs_route_short_name",
|
|
17
|
+
trip.gtfs_route_type AS "trip.gtfs_route_type",
|
|
18
|
+
trip.gtfs_trip_headsign AS "trip.gtfs_trip_headsign",
|
|
19
|
+
trip.gtfs_trip_short_name AS "trip.gtfs_trip_short_name",
|
|
20
|
+
trip.gtfs_trip_id AS "trip.gtfs_trip_id",
|
|
21
|
+
trip.gtfs_date AS "trip.gtfs_date",
|
|
22
|
+
trip.id AS "trip.id",
|
|
23
|
+
trip.is_canceled AS "trip.is_canceled",
|
|
24
|
+
trip.last_position_id AS "trip.last_position_id",
|
|
25
|
+
trip.origin_route_name AS "trip.origin_route_name",
|
|
26
|
+
trip.run_number AS "trip.run_number",
|
|
27
|
+
trip.start_asw_stop_id AS "trip.start_asw_stop_id",
|
|
28
|
+
trip.start_cis_stop_id AS "trip.start_cis_stop_id",
|
|
29
|
+
trip.start_cis_stop_platform_code AS "trip.start_cis_stop_platform_code",
|
|
30
|
+
trip.start_time AS "trip.start_time",
|
|
31
|
+
trip.start_timestamp AS "trip.start_timestamp",
|
|
32
|
+
trip.end_timestamp AS "trip.end_timestamp",
|
|
33
|
+
trip.vehicle_registration_number AS "trip.vehicle_registration_number",
|
|
34
|
+
trip.vehicle_type_id AS "trip.vehicle_type_id",
|
|
35
|
+
trip.wheelchair_accessible AS "trip.wheelchair_accessible",
|
|
36
|
+
trip.internal_route_name AS "trip.internal_route_name",
|
|
37
|
+
trip.internal_run_number AS "trip.internal_run_number",
|
|
38
|
+
"trip->last_position".asw_last_stop_id AS "trip.last_position.asw_last_stop_id",
|
|
39
|
+
"trip->last_position".bearing AS "trip.last_position.bearing",
|
|
40
|
+
"trip->last_position".cis_last_stop_id AS "trip.last_position.cis_last_stop_id",
|
|
41
|
+
"trip->last_position".cis_last_stop_sequence AS "trip.last_position.cis_last_stop_sequence",
|
|
42
|
+
"trip->last_position".delay AS "trip.last_position.delay",
|
|
43
|
+
"trip->last_position".delay_stop_arrival AS "trip.last_position.delay_stop_arrival",
|
|
44
|
+
"trip->last_position".delay_stop_departure AS "trip.last_position.delay_stop_departure",
|
|
45
|
+
"trip->last_position".id AS "trip.last_position.id",
|
|
46
|
+
"trip->last_position".is_canceled AS "trip.last_position.is_canceled",
|
|
47
|
+
"trip->last_position".last_stop_arrival_time AS "trip.last_position.last_stop_arrival_time",
|
|
48
|
+
"trip->last_position".last_stop_departure_time AS "trip.last_position.last_stop_departure_time",
|
|
49
|
+
"trip->last_position".last_stop_id AS "trip.last_position.last_stop_id",
|
|
50
|
+
"trip->last_position".last_stop_sequence AS "trip.last_position.last_stop_sequence",
|
|
51
|
+
"trip->last_position".lat AS "trip.last_position.lat",
|
|
52
|
+
"trip->last_position".lng AS "trip.last_position.lng",
|
|
53
|
+
"trip->last_position".next_stop_arrival_time AS "trip.last_position.next_stop_arrival_time",
|
|
54
|
+
"trip->last_position".next_stop_departure_time AS "trip.last_position.next_stop_departure_time",
|
|
55
|
+
"trip->last_position".next_stop_id AS "trip.last_position.next_stop_id",
|
|
56
|
+
"trip->last_position".next_stop_sequence AS "trip.last_position.next_stop_sequence",
|
|
57
|
+
"trip->last_position".origin_time AS "trip.last_position.origin_time",
|
|
58
|
+
"trip->last_position".origin_timestamp AS "trip.last_position.origin_timestamp",
|
|
59
|
+
"trip->last_position".shape_dist_traveled AS "trip.last_position.shape_dist_traveled",
|
|
60
|
+
"trip->last_position".speed AS "trip.last_position.speed",
|
|
61
|
+
"trip->last_position".state_position AS "trip.last_position.state_position",
|
|
62
|
+
"trip->last_position".state_process AS "trip.last_position.state_process",
|
|
63
|
+
"trip->last_position".this_stop_id AS "trip.last_position.this_stop_id",
|
|
64
|
+
"trip->last_position".this_stop_sequence AS "trip.last_position.this_stop_sequence",
|
|
65
|
+
"trip->last_position".is_tracked AS "trip.last_position.is_tracked",
|
|
66
|
+
"trip->last_position".trips_id AS "trip.last_position.trips_id",
|
|
67
|
+
"trip->last_position".tcp_event AS "trip.last_position.tcp_event",
|
|
68
|
+
"trip->last_position".last_stop_headsign AS "trip.last_position.last_stop_headsign",
|
|
69
|
+
"trip->last_position".last_stop_name AS "trip.last_position.last_stop_name",
|
|
70
|
+
"trip->last_position".valid_to AS "trip.last_position.valid_to",
|
|
71
|
+
"trip->last_position".scheduled_timestamp AS "trip.last_position.scheduled_timestamp",
|
|
72
|
+
"trip->vehicle_descriptor".id AS "trip.vehicle_descriptor.id",
|
|
73
|
+
"trip->vehicle_descriptor".is_air_conditioned AS "trip.vehicle_descriptor.is_air_conditioned"
|
|
74
|
+
FROM ((public_transport.vehiclepositions_trips trip
|
|
75
|
+
JOIN public_transport.vehiclepositions_positions "trip->last_position" ON (((trip.last_position_id = "trip->last_position".id) AND (("trip->last_position".valid_to IS NULL) OR ("trip->last_position".valid_to >= CURRENT_TIMESTAMP) OR (("trip->last_position".state_position)::text = ANY ((ARRAY['after_track'::character varying, 'after_track_delayed'::character varying])::text[]))) AND (("trip->last_position".state_position)::text = ANY ((ARRAY['at_stop'::character varying, 'before_track'::character varying, 'before_track_delayed'::character varying, 'canceled'::character varying, 'off_track'::character varying, 'on_track'::character varying, 'after_track'::character varying, 'after_track_delayed'::character varying])::text[])))))
|
|
76
|
+
LEFT JOIN public_transport.vehiclepositions_vehicle_descriptors "trip->vehicle_descriptor" ON (((trip.vehicle_registration_number = "trip->vehicle_descriptor".registration_number) AND (trip.gtfs_route_type = "trip->vehicle_descriptor".gtfs_route_type))));
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
-- trip.feed_id lets feed-scoped functions join vehicle positions without matching a same-named trip of another feed
|
|
2
|
+
CREATE OR REPLACE VIEW public_transport.v_vehiclepositions_trip_position_vehicle_info AS
|
|
3
|
+
SELECT "trip->last_position".delay AS delay_seconds,
|
|
4
|
+
trip.wheelchair_accessible AS real_wheelchair_accessible,
|
|
5
|
+
"trip->last_position".is_canceled,
|
|
6
|
+
trip.agency_name_real AS "trip.agency_name_real",
|
|
7
|
+
trip.agency_name_scheduled AS "trip.agency_name_scheduled",
|
|
8
|
+
trip.cis_line_id AS "trip.cis_line_id",
|
|
9
|
+
trip.cis_line_short_name AS "trip.cis_line_short_name",
|
|
10
|
+
trip.cis_trip_number AS "trip.cis_trip_number",
|
|
11
|
+
trip.gtfs_block_id AS "trip.gtfs_block_id",
|
|
12
|
+
trip.gtfs_route_id AS "trip.gtfs_route_id",
|
|
13
|
+
trip.gtfs_route_short_name AS "trip.gtfs_route_short_name",
|
|
14
|
+
trip.gtfs_route_type AS "trip.gtfs_route_type",
|
|
15
|
+
trip.gtfs_trip_headsign AS "trip.gtfs_trip_headsign",
|
|
16
|
+
trip.gtfs_trip_short_name AS "trip.gtfs_trip_short_name",
|
|
17
|
+
trip.gtfs_trip_id AS "trip.gtfs_trip_id",
|
|
18
|
+
trip.gtfs_date AS "trip.gtfs_date",
|
|
19
|
+
trip.id AS "trip.id",
|
|
20
|
+
trip.is_canceled AS "trip.is_canceled",
|
|
21
|
+
trip.last_position_id AS "trip.last_position_id",
|
|
22
|
+
trip.origin_route_name AS "trip.origin_route_name",
|
|
23
|
+
trip.run_number AS "trip.run_number",
|
|
24
|
+
trip.start_asw_stop_id AS "trip.start_asw_stop_id",
|
|
25
|
+
trip.start_cis_stop_id AS "trip.start_cis_stop_id",
|
|
26
|
+
trip.start_cis_stop_platform_code AS "trip.start_cis_stop_platform_code",
|
|
27
|
+
trip.start_time AS "trip.start_time",
|
|
28
|
+
trip.start_timestamp AS "trip.start_timestamp",
|
|
29
|
+
trip.end_timestamp AS "trip.end_timestamp",
|
|
30
|
+
trip.vehicle_registration_number AS "trip.vehicle_registration_number",
|
|
31
|
+
trip.vehicle_type_id AS "trip.vehicle_type_id",
|
|
32
|
+
trip.wheelchair_accessible AS "trip.wheelchair_accessible",
|
|
33
|
+
trip.internal_route_name AS "trip.internal_route_name",
|
|
34
|
+
trip.internal_run_number AS "trip.internal_run_number",
|
|
35
|
+
"trip->last_position".asw_last_stop_id AS "trip.last_position.asw_last_stop_id",
|
|
36
|
+
"trip->last_position".bearing AS "trip.last_position.bearing",
|
|
37
|
+
"trip->last_position".cis_last_stop_id AS "trip.last_position.cis_last_stop_id",
|
|
38
|
+
"trip->last_position".cis_last_stop_sequence AS "trip.last_position.cis_last_stop_sequence",
|
|
39
|
+
"trip->last_position".delay AS "trip.last_position.delay",
|
|
40
|
+
"trip->last_position".delay_stop_arrival AS "trip.last_position.delay_stop_arrival",
|
|
41
|
+
"trip->last_position".delay_stop_departure AS "trip.last_position.delay_stop_departure",
|
|
42
|
+
"trip->last_position".id AS "trip.last_position.id",
|
|
43
|
+
"trip->last_position".is_canceled AS "trip.last_position.is_canceled",
|
|
44
|
+
"trip->last_position".last_stop_arrival_time AS "trip.last_position.last_stop_arrival_time",
|
|
45
|
+
"trip->last_position".last_stop_departure_time AS "trip.last_position.last_stop_departure_time",
|
|
46
|
+
"trip->last_position".last_stop_id AS "trip.last_position.last_stop_id",
|
|
47
|
+
"trip->last_position".last_stop_sequence AS "trip.last_position.last_stop_sequence",
|
|
48
|
+
"trip->last_position".lat AS "trip.last_position.lat",
|
|
49
|
+
"trip->last_position".lng AS "trip.last_position.lng",
|
|
50
|
+
"trip->last_position".next_stop_arrival_time AS "trip.last_position.next_stop_arrival_time",
|
|
51
|
+
"trip->last_position".next_stop_departure_time AS "trip.last_position.next_stop_departure_time",
|
|
52
|
+
"trip->last_position".next_stop_id AS "trip.last_position.next_stop_id",
|
|
53
|
+
"trip->last_position".next_stop_sequence AS "trip.last_position.next_stop_sequence",
|
|
54
|
+
"trip->last_position".origin_time AS "trip.last_position.origin_time",
|
|
55
|
+
"trip->last_position".origin_timestamp AS "trip.last_position.origin_timestamp",
|
|
56
|
+
"trip->last_position".shape_dist_traveled AS "trip.last_position.shape_dist_traveled",
|
|
57
|
+
"trip->last_position".speed AS "trip.last_position.speed",
|
|
58
|
+
"trip->last_position".state_position AS "trip.last_position.state_position",
|
|
59
|
+
"trip->last_position".state_process AS "trip.last_position.state_process",
|
|
60
|
+
"trip->last_position".this_stop_id AS "trip.last_position.this_stop_id",
|
|
61
|
+
"trip->last_position".this_stop_sequence AS "trip.last_position.this_stop_sequence",
|
|
62
|
+
"trip->last_position".is_tracked AS "trip.last_position.is_tracked",
|
|
63
|
+
"trip->last_position".trips_id AS "trip.last_position.trips_id",
|
|
64
|
+
"trip->last_position".tcp_event AS "trip.last_position.tcp_event",
|
|
65
|
+
"trip->last_position".last_stop_headsign AS "trip.last_position.last_stop_headsign",
|
|
66
|
+
"trip->last_position".last_stop_name AS "trip.last_position.last_stop_name",
|
|
67
|
+
"trip->last_position".valid_to AS "trip.last_position.valid_to",
|
|
68
|
+
"trip->last_position".scheduled_timestamp AS "trip.last_position.scheduled_timestamp",
|
|
69
|
+
"trip->vehicle_descriptor".id AS "trip.vehicle_descriptor.id",
|
|
70
|
+
"trip->vehicle_descriptor".is_air_conditioned AS "trip.vehicle_descriptor.is_air_conditioned",
|
|
71
|
+
trip.feed_id AS "trip.feed_id"
|
|
72
|
+
FROM ((public_transport.vehiclepositions_trips trip
|
|
73
|
+
JOIN public_transport.vehiclepositions_positions "trip->last_position" ON (((trip.last_position_id = "trip->last_position".id) AND (("trip->last_position".valid_to IS NULL) OR ("trip->last_position".valid_to >= CURRENT_TIMESTAMP) OR (("trip->last_position".state_position)::text = ANY ((ARRAY['after_track'::character varying, 'after_track_delayed'::character varying])::text[]))) AND (("trip->last_position".state_position)::text = ANY ((ARRAY['at_stop'::character varying, 'before_track'::character varying, 'before_track_delayed'::character varying, 'canceled'::character varying, 'off_track'::character varying, 'on_track'::character varying, 'after_track'::character varying, 'after_track_delayed'::character varying])::text[])))))
|
|
74
|
+
LEFT JOIN public_transport.vehiclepositions_vehicle_descriptors "trip->vehicle_descriptor" ON (((trip.vehicle_registration_number = "trip->vehicle_descriptor".registration_number) AND (trip.gtfs_route_type = "trip->vehicle_descriptor".gtfs_route_type))));
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
-- Feed-scoped variant of get_departures: trip_id and stop_id are unique only within a feed, and an empty
|
|
78
|
+
-- (NULL) pickup_type/drop_off_type means regular pickup/drop off per the GTFS spec
|
|
79
|
+
CREATE FUNCTION public_transport.get_feed_departures(feedid integer, stopsids character varying, mode integer, datedeparturebetweenstart timestamp with time zone, datedeparturebetweenend timestamp with time zone, isnegativeminutesbefore integer, datecanceleddeparturebetweenstart timestamp with time zone, datecanceleddeparturebetweenend timestamp with time zone, airconditioninfoenabled integer) RETURNS TABLE(departure_datetime_real timestamp with time zone, arrival_datetime_real timestamp with time zone, stop_sequence smallint, stop_headsign character varying, arrival_datetime timestamp with time zone, departure_datetime timestamp with time zone, stop_id character varying, platform_code character varying, wheelchair_boarding smallint, min_stop_sequence smallint, max_stop_sequence smallint, trip_id character varying, trip_headsign character varying, trip_short_name character varying, wheelchair_accessible smallint, route_short_name character varying, route_type smallint, route_id character varying, is_night character, is_regional character, is_substitute_transport character, next_stop_id character varying, next_route_short_name text, next_trip_headsign text, max_stop_sequence_with_stop_headsign integer, delay_seconds integer, real_wheelchair_accessible boolean, is_canceled boolean, "trip.gtfs_trip_short_name" character varying, "trip.gtfs_date" date, "trip.internal_route_name" character varying, "trip.internal_run_number" integer, "trip.start_timestamp" timestamp with time zone, "trip.last_position.state_position" character varying, "trip.last_position.last_stop_id" character varying, "trip.last_position.last_stop_sequence" integer, "trip.last_position.last_stop_name" character varying, "trip.last_position.this_stop_sequence" integer, "trip.cis_stop_platform_code" character varying, "trip.vehicle_descriptor.is_air_conditioned" boolean, delay_minutes integer, is_delay_available boolean, run_number integer, planned_start_timestamp timestamp with time zone)
|
|
80
|
+
LANGUAGE sql
|
|
81
|
+
SET search_path TO 'public_transport', 'public'
|
|
82
|
+
AS $$
|
|
83
|
+
select
|
|
84
|
+
departure_boards_detailed."computed.departure_datetime_real",
|
|
85
|
+
departure_boards_detailed."computed.arrival_datetime_real",
|
|
86
|
+
departure_boards_detailed."gtfs_precomputed_departures.stop_sequence",
|
|
87
|
+
departure_boards_detailed."gtfs_precomputed_departures.stop_headsign",
|
|
88
|
+
departure_boards_detailed."gtfs_precomputed_departures.arrival_datetime",
|
|
89
|
+
departure_boards_detailed."gtfs_precomputed_departures.departure_datetime",
|
|
90
|
+
departure_boards_detailed."gtfs_precomputed_departures.stop_id",
|
|
91
|
+
departure_boards_detailed."gtfs_precomputed_departures.platform_code",
|
|
92
|
+
departure_boards_detailed."gtfs_precomputed_departures.wheelchair_boarding",
|
|
93
|
+
departure_boards_detailed."gtfs_precomputed_departures.min_stop_sequence",
|
|
94
|
+
departure_boards_detailed."gtfs_precomputed_departures.max_stop_sequence",
|
|
95
|
+
departure_boards_detailed."gtfs_precomputed_departures.trip_id",
|
|
96
|
+
departure_boards_detailed."gtfs_precomputed_departures.trip_headsign",
|
|
97
|
+
departure_boards_detailed."gtfs_precomputed_departures.trip_short_name",
|
|
98
|
+
departure_boards_detailed."gtfs_precomputed_departures.wheelchair_accessible",
|
|
99
|
+
departure_boards_detailed."gtfs_precomputed_departures.route_short_name",
|
|
100
|
+
departure_boards_detailed."gtfs_precomputed_departures.route_type",
|
|
101
|
+
departure_boards_detailed."gtfs_precomputed_departures.route_id",
|
|
102
|
+
departure_boards_detailed."gtfs_precomputed_departures.is_night",
|
|
103
|
+
departure_boards_detailed."gtfs_precomputed_departures.is_regional",
|
|
104
|
+
departure_boards_detailed."gtfs_precomputed_departures.is_substitute_transport",
|
|
105
|
+
departure_boards_detailed."gtfs_precomputed_departures.next_stop_id",
|
|
106
|
+
departure_boards_detailed."gtfs_precomputed_departures.next_route_short_name",
|
|
107
|
+
departure_boards_detailed."gtfs_precomputed_departures.next_trip_headsign",
|
|
108
|
+
departure_boards_detailed."gtfs_precomputed_departures.max_stop_sequence_with_stop_headsign",
|
|
109
|
+
departure_boards_detailed."delay_seconds",
|
|
110
|
+
departure_boards_detailed."real_wheelchair_accessible",
|
|
111
|
+
departure_boards_detailed."is_canceled",
|
|
112
|
+
departure_boards_detailed."trip.gtfs_trip_short_name",
|
|
113
|
+
departure_boards_detailed."trip.gtfs_date",
|
|
114
|
+
departure_boards_detailed."trip.internal_route_name",
|
|
115
|
+
departure_boards_detailed."trip.internal_run_number",
|
|
116
|
+
departure_boards_detailed."trip.start_timestamp",
|
|
117
|
+
departure_boards_detailed."trip.last_position.state_position",
|
|
118
|
+
departure_boards_detailed."trip.last_position.last_stop_id",
|
|
119
|
+
departure_boards_detailed."trip.last_position.last_stop_sequence",
|
|
120
|
+
departure_boards_detailed."trip.last_position.last_stop_name",
|
|
121
|
+
departure_boards_detailed."trip.last_position.this_stop_sequence",
|
|
122
|
+
departure_boards_detailed.cis_stop_platform_code as "trip.cis_stop_platform_code",
|
|
123
|
+
case when airconditioninfoenabled = 1 then departure_boards_detailed."trip.vehicle_descriptor.is_air_conditioned" else NULL end,
|
|
124
|
+
TRUNC(departure_boards_detailed."trip.last_position.delay"::DECIMAL / 60, 0)::int as "delay_minutes",
|
|
125
|
+
case when departure_boards_detailed."trip.last_position.delay" is null then false else true end as "is_delay_available",
|
|
126
|
+
departure_boards_detailed."run.run_number",
|
|
127
|
+
departure_boards_detailed.planned_start_timestamp
|
|
128
|
+
|
|
129
|
+
from (
|
|
130
|
+
select
|
|
131
|
+
("departure_datetime"
|
|
132
|
+
+ MAKE_INTERVAL(secs => (case when "trip.last_position.delay" is null then 0 else "trip.last_position.delay" end))
|
|
133
|
+
- case when (MAKE_INTERVAL(secs => (case when "trip.last_position.delay" is null then 0 else "trip.last_position.delay" end)) > MAKE_INTERVAL())
|
|
134
|
+
then least (
|
|
135
|
+
MAKE_INTERVAL(secs => (case when "trip.last_position.delay" is null then 0 else "trip.last_position.delay" end)),
|
|
136
|
+
("departure_datetime" - "arrival_datetime")::interval
|
|
137
|
+
)
|
|
138
|
+
else MAKE_INTERVAL()
|
|
139
|
+
end
|
|
140
|
+
) "computed.departure_datetime_real",
|
|
141
|
+
"arrival_datetime" + MAKE_INTERVAL(secs => (
|
|
142
|
+
CASE WHEN "trip.last_position.delay" IS NULL THEN 0 ELSE "trip.last_position.delay" end
|
|
143
|
+
)) "computed.arrival_datetime_real",
|
|
144
|
+
"gtfs_precomputed_departures"."stop_sequence" as "gtfs_precomputed_departures.stop_sequence",
|
|
145
|
+
"gtfs_precomputed_departures"."stop_headsign" as "gtfs_precomputed_departures.stop_headsign",
|
|
146
|
+
"gtfs_precomputed_departures"."pickup_type" as "gtfs_precomputed_departures.pickup_type",
|
|
147
|
+
"gtfs_precomputed_departures"."drop_off_type" as "gtfs_precomputed_departures.drop_off_type",
|
|
148
|
+
"gtfs_precomputed_departures"."arrival_time" as "gtfs_precomputed_departures.arrival_time",
|
|
149
|
+
"gtfs_precomputed_departures"."arrival_datetime" as "gtfs_precomputed_departures.arrival_datetime",
|
|
150
|
+
"gtfs_precomputed_departures"."departure_time" as "gtfs_precomputed_departures.departure_time",
|
|
151
|
+
"gtfs_precomputed_departures"."departure_datetime" as "gtfs_precomputed_departures.departure_datetime",
|
|
152
|
+
"gtfs_precomputed_departures"."stop_id" as "gtfs_precomputed_departures.stop_id",
|
|
153
|
+
"gtfs_precomputed_departures"."stop_name" as "gtfs_precomputed_departures.stop_name",
|
|
154
|
+
"gtfs_precomputed_departures"."platform_code" as "gtfs_precomputed_departures.platform_code",
|
|
155
|
+
"gtfs_precomputed_departures"."wheelchair_boarding" as "gtfs_precomputed_departures.wheelchair_boarding",
|
|
156
|
+
"gtfs_precomputed_departures"."min_stop_sequence" as "gtfs_precomputed_departures.min_stop_sequence",
|
|
157
|
+
"gtfs_precomputed_departures"."max_stop_sequence" as "gtfs_precomputed_departures.max_stop_sequence",
|
|
158
|
+
"gtfs_precomputed_departures"."trip_id" as "gtfs_precomputed_departures.trip_id",
|
|
159
|
+
"gtfs_precomputed_departures"."trip_headsign" as "gtfs_precomputed_departures.trip_headsign",
|
|
160
|
+
"gtfs_precomputed_departures"."trip_short_name" as "gtfs_precomputed_departures.trip_short_name",
|
|
161
|
+
"gtfs_precomputed_departures"."wheelchair_accessible" as "gtfs_precomputed_departures.wheelchair_accessible",
|
|
162
|
+
"gtfs_precomputed_departures"."service_id" as "gtfs_precomputed_departures.service_id",
|
|
163
|
+
"gtfs_precomputed_departures"."date" as "gtfs_precomputed_departures.date",
|
|
164
|
+
"gtfs_precomputed_departures"."route_short_name" as "gtfs_precomputed_departures.route_short_name",
|
|
165
|
+
"gtfs_precomputed_departures"."route_type" as "gtfs_precomputed_departures.route_type",
|
|
166
|
+
"gtfs_precomputed_departures"."route_id" as "gtfs_precomputed_departures.route_id",
|
|
167
|
+
"gtfs_precomputed_departures"."is_night" as "gtfs_precomputed_departures.is_night",
|
|
168
|
+
"gtfs_precomputed_departures"."is_regional" as "gtfs_precomputed_departures.is_regional",
|
|
169
|
+
"gtfs_precomputed_departures"."is_substitute_transport" as "gtfs_precomputed_departures.is_substitute_transport",
|
|
170
|
+
"gtfs_precomputed_departures"."next_stop_sequence" as "gtfs_precomputed_departures.next_stop_sequence",
|
|
171
|
+
"gtfs_precomputed_departures"."next_stop_id" as "gtfs_precomputed_departures.next_stop_id",
|
|
172
|
+
"gtfs_precomputed_departures"."last_stop_sequence" as "gtfs_precomputed_departures.last_stop_sequence",
|
|
173
|
+
"gtfs_precomputed_departures"."last_stop_id" as "gtfs_precomputed_departures.last_stop_id",
|
|
174
|
+
"gtfs_precomputed_departures"."next_route_short_name" as "gtfs_precomputed_departures.next_route_short_name",
|
|
175
|
+
"gtfs_precomputed_departures"."next_trip_headsign" as "gtfs_precomputed_departures.next_trip_headsign",
|
|
176
|
+
"gtfs_precomputed_departures"."max_stop_sequence_with_stop_headsign" as "gtfs_precomputed_departures.max_stop_sequence_with_stop_headsign",
|
|
177
|
+
plan_start.planned_departure AS planned_start_timestamp,
|
|
178
|
+
x.*,
|
|
179
|
+
cis_stop.cis_stop_platform_code as "cis_stop_platform_code",
|
|
180
|
+
run.run_number as "run.run_number"
|
|
181
|
+
from
|
|
182
|
+
"gtfs_precomputed_departures" as "gtfs_precomputed_departures"
|
|
183
|
+
left join "gtfs_run_numbers" as run on
|
|
184
|
+
"gtfs_precomputed_departures"."trip_id" = run.trip_id
|
|
185
|
+
and "gtfs_precomputed_departures"."service_id" = run.service_id
|
|
186
|
+
and run.feed_id = feedid
|
|
187
|
+
left outer join v_vehiclepositions_trip_position_vehicle_info as x on
|
|
188
|
+
"gtfs_precomputed_departures"."trip_id" = x."trip.gtfs_trip_id"
|
|
189
|
+
and x."trip.feed_id" = feedid
|
|
190
|
+
left join lateral (
|
|
191
|
+
select pd.departure_datetime as planned_departure
|
|
192
|
+
from gtfs_precomputed_departures pd
|
|
193
|
+
where pd.trip_id = "gtfs_precomputed_departures".trip_id
|
|
194
|
+
and pd.date = "gtfs_precomputed_departures".date
|
|
195
|
+
and pd.stop_sequence = 1
|
|
196
|
+
and pd.feed_id = feedid
|
|
197
|
+
limit 1
|
|
198
|
+
) as plan_start on true
|
|
199
|
+
left join vehiclepositions_cis_stops as cis_stop on
|
|
200
|
+
cis_stop.rt_trip_id = x."trip.id"
|
|
201
|
+
and cis_stop.cis_stop_group_id = "gtfs_precomputed_departures"."cis_stop_group_id"
|
|
202
|
+
where "gtfs_precomputed_departures".feed_id = feedid
|
|
203
|
+
) departure_boards_detailed
|
|
204
|
+
where
|
|
205
|
+
departure_boards_detailed."gtfs_precomputed_departures.stop_id" = ANY(STRING_TO_ARRAY(stopsIds,','))
|
|
206
|
+
and (
|
|
207
|
+
(
|
|
208
|
+
(
|
|
209
|
+
(mode = 1 and departure_boards_detailed."computed.arrival_datetime_real" between dateDepartureBetweenStart and dateDepartureBetweenEnd)
|
|
210
|
+
or (mode != 1 and departure_boards_detailed."computed.departure_datetime_real" between dateDepartureBetweenStart and dateDepartureBetweenEnd)
|
|
211
|
+
)
|
|
212
|
+
and
|
|
213
|
+
(
|
|
214
|
+
0 = isNegativeMinutesBefore
|
|
215
|
+
or ( -- pro záporné minutes before
|
|
216
|
+
departure_boards_detailed."gtfs_precomputed_departures.stop_sequence" >= departure_boards_detailed."trip.last_position.last_stop_sequence"
|
|
217
|
+
or departure_boards_detailed."trip.last_position.last_stop_sequence" IS null
|
|
218
|
+
)
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
)
|
|
222
|
+
or (
|
|
223
|
+
departure_boards_detailed."trip.is_canceled" = true
|
|
224
|
+
and
|
|
225
|
+
(
|
|
226
|
+
(mode = 1 and departure_boards_detailed."computed.arrival_datetime_real" between dateCanceledDepartureBetweenStart and dateCanceledDepartureBetweenEnd)
|
|
227
|
+
or (mode != 1 and departure_boards_detailed."computed.departure_datetime_real" between dateCanceledDepartureBetweenStart and dateCanceledDepartureBetweenEnd)
|
|
228
|
+
)
|
|
229
|
+
)
|
|
230
|
+
) and
|
|
231
|
+
(
|
|
232
|
+
(mode = 1 and (coalesce(departure_boards_detailed."gtfs_precomputed_departures.pickup_type", '0') != '1' and departure_boards_detailed."gtfs_precomputed_departures.stop_sequence" != departure_boards_detailed."gtfs_precomputed_departures.max_stop_sequence")) -- mode default/departures
|
|
233
|
+
or (mode=2 and (coalesce(departure_boards_detailed."gtfs_precomputed_departures.drop_off_type", '0') != '1' and departure_boards_detailed."gtfs_precomputed_departures.stop_sequence" != departure_boards_detailed."gtfs_precomputed_departures.min_stop_sequence")) -- mode arrivals
|
|
234
|
+
or (mode=3 and (coalesce(departure_boards_detailed."gtfs_precomputed_departures.pickup_type", '0') != '1')) -- mode mixed
|
|
235
|
+
);
|
|
236
|
+
$$;
|
|
@@ -6,5 +6,5 @@ export declare class RunTripsRedisRepository implements IRunTripsRedisRepository
|
|
|
6
6
|
private redisConnector;
|
|
7
7
|
private log;
|
|
8
8
|
constructor(redisConnector: IoRedisConnector, log: ILogger);
|
|
9
|
-
getMultipleSchedule(runTuples: string[]): Promise<Array<IGtfsRunTripCacheDto | null>>;
|
|
9
|
+
getMultipleSchedule(feedId: number, runTuples: string[]): Promise<Array<IGtfsRunTripCacheDto | null>>;
|
|
10
10
|
}
|
|
@@ -13,7 +13,6 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.RunTripsRedisRepository = void 0;
|
|
16
|
-
const constants_1 = require("../../../shared/constants");
|
|
17
16
|
const const_1 = require("../../../../schema-definitions/gtfs/redis/const");
|
|
18
17
|
const IoRedisConnector_1 = require("@golemio/core/dist/helpers/data-access/redis/IoRedisConnector");
|
|
19
18
|
const CoreToken_1 = require("@golemio/core/dist/helpers/ioc/CoreToken");
|
|
@@ -25,7 +24,7 @@ let RunTripsRedisRepository = class RunTripsRedisRepository {
|
|
|
25
24
|
this.redisConnector = redisConnector;
|
|
26
25
|
this.log = log;
|
|
27
26
|
}
|
|
28
|
-
async getMultipleSchedule(runTuples) {
|
|
27
|
+
async getMultipleSchedule(feedId, runTuples) {
|
|
29
28
|
if (!runTuples.length) {
|
|
30
29
|
return [];
|
|
31
30
|
}
|
|
@@ -35,9 +34,8 @@ let RunTripsRedisRepository = class RunTripsRedisRepository {
|
|
|
35
34
|
const connection = this.redisConnector.getConnection();
|
|
36
35
|
let runTripCache = [];
|
|
37
36
|
try {
|
|
38
|
-
// IE writes run schedules under feed-namespaced keys (`<prefix>:<feedId>_<route>_<run>`)
|
|
39
|
-
|
|
40
|
-
runTripCache = await connection.mget(runTuples.map((runTuple) => `${const_1.GTFS_RUN_SCHEDULE_NAMESPACE_PREFIX}:${constants_1.PID_FEED_ID}_${runTuple}`));
|
|
37
|
+
// IE writes run schedules under feed-namespaced keys (`<prefix>:<feedId>_<route>_<run>`)
|
|
38
|
+
runTripCache = await connection.mget(runTuples.map((runTuple) => `${const_1.GTFS_RUN_SCHEDULE_NAMESPACE_PREFIX}:${feedId}_${runTuple}`));
|
|
41
39
|
}
|
|
42
40
|
catch (error) {
|
|
43
41
|
throw new golemio_errors_1.GeneralError("Cannot get run trips from cache", this.constructor.name, error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RunTripsRedisRepository.js","sourceRoot":"","sources":["../../../../../src/output-gateway/gtfs/data-access/redis/RunTripsRedisRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,
|
|
1
|
+
{"version":3,"file":"RunTripsRedisRepository.js","sourceRoot":"","sources":["../../../../../src/output-gateway/gtfs/data-access/redis/Run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AC;gBACtE,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAC3B,SAAS;YACb,CAAC;YAED,IAAI,CAAC;gBACD,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;YAC5C,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACb,MAAM,IAAI,6BAAY,CAAC,6BAA6B,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YACxF,CAAC;QACL,CAAC;QAED,OAAO,eAAe,CAAC;IAC3B,CAAC;CACJ,CAAA;AA5CY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,qBAAU,GAAE;IAGJ,WAAA,IAAA,iBAAM,EAAC,oBAAc,CAAC,cAAc,CAAC,CAAA;IACrC,WAAA,IAAA,iBAAM,EAAC,qBAAS,CAAC,MAAM,CAAC,CAAA;qCADsC,mCAAgB;GAF1E,uBAAuB,CA4CnC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { IGtfsRunTripCacheDto } from "../../../../schema-definitions/vehicle-positions/redis/interfaces/IGtfsRunTripCacheDto";
|
|
2
2
|
export interface IRunTripsRedisRepository {
|
|
3
|
-
getMultipleSchedule(runTuples: string[]): Promise<Array<IGtfsRunTripCacheDto | null>>;
|
|
3
|
+
getMultipleSchedule(feedId: number, runTuples: string[]): Promise<Array<IGtfsRunTripCacheDto | null>>;
|
|
4
4
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IStopTime } from "../../../schema-definitions/gtfs/redis/interfaces/IDelayComputationDto";
|
|
1
2
|
import { SequelizeModel } from "@golemio/core/dist/output-gateway";
|
|
2
3
|
import { IGTFSModels } from "./interfaces/IGTFSModels";
|
|
3
4
|
export declare class GTFSStopTimesModel extends SequelizeModel {
|
|
@@ -24,6 +25,11 @@ export declare class GTFSStopTimesModel extends SequelizeModel {
|
|
|
24
25
|
stop?: boolean;
|
|
25
26
|
feedId?: number;
|
|
26
27
|
}) => Promise<any>;
|
|
28
|
+
/**
|
|
29
|
+
* Stop times of one trip with their stops, in the shape of the delay computation cache.
|
|
30
|
+
* Trip and stop ids are only unique per feed, so both are scoped to the feed.
|
|
31
|
+
*/
|
|
32
|
+
getTripStopTimesWithStops: (tripId: string, feedId: number) => Promise<IStopTime[]>;
|
|
27
33
|
GetOne: (id: any) => Promise<any>;
|
|
28
34
|
private static arrivalTimeComparison;
|
|
29
35
|
}
|
|
@@ -101,6 +101,46 @@ class GTFSStopTimesModel extends output_gateway_1.SequelizeModel {
|
|
|
101
101
|
throw new golemio_errors_1.GeneralError("Database error", "GTFSStopTimesModel", err, 500);
|
|
102
102
|
}
|
|
103
103
|
};
|
|
104
|
+
/**
|
|
105
|
+
* Stop times of one trip with their stops, in the shape of the delay computation cache.
|
|
106
|
+
* Trip and stop ids are only unique per feed, so both are scoped to the feed.
|
|
107
|
+
*/
|
|
108
|
+
this.getTripStopTimesWithStops = async (tripId, feedId) => {
|
|
109
|
+
try {
|
|
110
|
+
const stopTimes = await this.sequelizeModel.findAll({
|
|
111
|
+
attributes: [
|
|
112
|
+
"arrival_time",
|
|
113
|
+
"departure_time",
|
|
114
|
+
"shape_dist_traveled",
|
|
115
|
+
"stop_headsign",
|
|
116
|
+
"stop_id",
|
|
117
|
+
"stop_sequence",
|
|
118
|
+
[sequelize_1.default.literal(`EXTRACT(EPOCH FROM "arrival_time"::INTERVAL)::int`), "arrival_time_seconds"],
|
|
119
|
+
[sequelize_1.default.literal(`EXTRACT(EPOCH FROM "departure_time"::INTERVAL)::int`), "departure_time_seconds"],
|
|
120
|
+
[
|
|
121
|
+
sequelize_1.default.literal(`CASE when drop_off_type = '1' and pickup_type = '1' then true else false END`),
|
|
122
|
+
"is_no_stop_waypoint",
|
|
123
|
+
],
|
|
124
|
+
"stop_icons",
|
|
125
|
+
],
|
|
126
|
+
include: [
|
|
127
|
+
{
|
|
128
|
+
as: "stop",
|
|
129
|
+
attributes: ["stop_id", "stop_lat", "stop_lon", "stop_name", "zone_id", "wheelchair_boarding"],
|
|
130
|
+
model: this.dbConnector.getConnection().models[gtfs_1.Gtfs.stops.pgTableName],
|
|
131
|
+
where: { feed_id: feedId },
|
|
132
|
+
required: true,
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
where: { trip_id: tripId, feed_id: feedId },
|
|
136
|
+
order: [["stop_sequence", "ASC"]],
|
|
137
|
+
});
|
|
138
|
+
return stopTimes.map((stopTime) => stopTime.get({ plain: true }));
|
|
139
|
+
}
|
|
140
|
+
catch (err) {
|
|
141
|
+
throw new golemio_errors_1.GeneralError("Database error ~ getTripStopTimesWithStops", "GTFSStopTimesModel", err, 500);
|
|
142
|
+
}
|
|
143
|
+
};
|
|
104
144
|
this.GetOne = (id) => {
|
|
105
145
|
throw new golemio_errors_1.FatalError("Method not implemented");
|
|
106
146
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GTFSStopTimesModel.js","sourceRoot":"","sources":["../../../../src/output-gateway/gtfs/models/GTFSStopTimesModel.ts"],"names":[],"mappings":";;;;;;AAAA,6DAAuC;AACvC,2DAAiC;AACjC,uFAA6D;
|
|
1
|
+
{"version":3,"file":"GTFSStopTimesModel.js","sourceRoot":"","sources":["../../../../src/output-gateway/gtfs/models/GTFSStopTimesModel.ts"],"names":[],"mappings":";;;;;;AAAA,6DAAuC;AACvC,2DAAiC;AACjC,uFAA6D;AAG7D,sEAAmE;AACnE,gEAAgG;AAChG,6EAAoF;AACpF,oFAA6E;AAG7E,MAAa,kBAAmB,SAAQ,+BAAc;IAGlD;QACI,KAAK,CAAC,WAAI,CAAC,UAAU,CAAC,IAAI,EAAE,WAAI,CAAC,UAAU,CAAC,WAAW,EAAE,2BAAY,CAAC,cAAc,EAAE;YAClF,MAAM,EAAE,iBAAS;SACpB,CAAC,CAAC;QAIA,cAAS,GAAG,CAAC,MAAmB,EAAE,EAAE;YACvC,IAAI,CAAC,cAAc,CAAC,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4C,EAAE,oBAAoB,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;YACzG,CAAC;QACL,CAAC,CAAC;QAEK,WAAM,GAAG,CAAC,EAAO,EAAgB,EAAE;YACtC,MAAM,IAAI,2BAAU,CAAC,wBAAwB,CAAC,CAAC;QACnD,CAAC,CAAC;QAnJE,IAAI,CAAC,WAAW,GAAG,4BAAsB,CAAC,OAAO,CAAqB,oBAAc,CAAC,gBAAgB,CAAC,CAAC;IAC3G,CAAC;;AARL,gDAgKC;AAJkB,wCAAqB,GAAG,CAAC,IAAY,EAAE,QAAqB,EAA2B,EAAE;IACpG,oCAAoC;IACpC,OAAO,mBAAS,CAAC,OAAO,CAAC,IAAI,IAAI,WAAW,QAAQ,uCAAuC,CAAC,CAAC;AACjG,CAAC,AAHmC,CAGlC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export * as PID from "./pid";
|
|
2
2
|
export * as Gtfs from "./gtfs";
|
|
3
3
|
export * as VehiclePositions from "./vehicle-positions";
|
|
4
|
-
export declare const routers: import("@golemio/core/dist/helpers/routing/AbstractRouter").AbstractRouter[];
|
|
4
|
+
export declare const routers: (import("@golemio/core/dist/helpers/routing/AbstractRouter").AbstractRouter | import("./public/routers/v1/V1DepartureBoardsRouter").V1DepartureBoardsRouter)[];
|
|
@@ -39,6 +39,7 @@ exports.routers = exports.VehiclePositions = exports.Gtfs = exports.PID = void 0
|
|
|
39
39
|
// import { v2PublicDeparturesRouter, v2PublicGtfsRouter } from "#og/public";
|
|
40
40
|
// imported from its own file: the #og/public barrel would also construct the disabled departures/GTFS routers
|
|
41
41
|
const V2PublicVehiclePositionsRouter_1 = require("./public/routers/v2/V2PublicVehiclePositionsRouter");
|
|
42
|
+
const V1DepartureBoardsRouter_1 = require("./public/routers/v1/V1DepartureBoardsRouter");
|
|
42
43
|
const gtfs_1 = require("./gtfs");
|
|
43
44
|
const vehicle_positions_1 = require("./vehicle-positions");
|
|
44
45
|
// import { v1JisRouter } from "./jis/routers/v1";
|
|
@@ -54,6 +55,9 @@ exports.routers = [
|
|
|
54
55
|
// multi-feed live positions from the public trip cache
|
|
55
56
|
V2PublicVehiclePositionsRouter_1.v2PublicVPRouter,
|
|
56
57
|
//#endregion
|
|
58
|
+
//#region Departure boards of any feed (?feed=<feedCode>)
|
|
59
|
+
V1DepartureBoardsRouter_1.v1DepartureBoardsRouter,
|
|
60
|
+
//#endregion
|
|
57
61
|
//#region PID Departure boards — out of scope for public-transport
|
|
58
62
|
// v2PidRouter,
|
|
59
63
|
// v3PidRouter,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/output-gateway/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mHAAmH;AACnH,mEAAmE;AACnE,6EAA6E;AAC7E,8GAA8G;AAC9G,uGAAwF;AACxF,iCAAwC;AACxC,2DAAiE;AACjE,kDAAkD;AAElD,6CAA6B;AAC7B,+CAA+B;AAC/B,wEAAwD;AAE3C,QAAA,OAAO,GAAG;IACnB,cAAc;IACd,mBAAY;IACZ,YAAY;IAEZ,uDAAuD;IACvD,4CAAwB;IACxB,uDAAuD;IACvD,iDAAgB;IAChB,YAAY;IAEZ,kEAAkE;IAClE,eAAe;IACf,eAAe;IACf,eAAe;IACf,YAAY;IAEZ,8DAA8D;IAC9D,4BAA4B;IAC5B,sBAAsB;IACtB,YAAY;IAEZ,2DAA2D;IAC3D,eAAe;IACf,YAAY;CACf,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/output-gateway/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mHAAmH;AACnH,mEAAmE;AACnE,6EAA6E;AAC7E,8GAA8G;AAC9G,uGAAwF;AACxF,yFAAwF;AACxF,iCAAwC;AACxC,2DAAiE;AACjE,kDAAkD;AAElD,6CAA6B;AAC7B,+CAA+B;AAC/B,wEAAwD;AAE3C,QAAA,OAAO,GAAG;IACnB,cAAc;IACd,mBAAY;IACZ,YAAY;IAEZ,uDAAuD;IACvD,4CAAwB;IACxB,uDAAuD;IACvD,iDAAgB;IAChB,YAAY;IAEZ,yDAAyD;IACzD,iDAAuB;IACvB,YAAY;IAEZ,kEAAkE;IAClE,eAAe;IACf,eAAe;IACf,eAAe;IACf,YAAY;IAEZ,8DAA8D;IAC9D,4BAA4B;IAC5B,sBAAsB;IACtB,YAAY;IAEZ,2DAA2D;IAC3D,eAAe;IACf,YAAY;CACf,CAAC"}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { RequestHandler } from "@golemio/core/dist/shared/express";
|
|
2
2
|
export declare class V2DepartureBoardsController {
|
|
3
3
|
private departureBoardsModel;
|
|
4
|
+
private feedRepository;
|
|
4
5
|
constructor();
|
|
5
6
|
getDepartureBoard: RequestHandler;
|
|
7
|
+
/**
|
|
8
|
+
* Departure board of the feed given by the `feed` query param (a gtfs_feeds.code value), stops by GTFS ids or names
|
|
9
|
+
*/
|
|
10
|
+
getFeedDepartureBoard: RequestHandler;
|
|
6
11
|
getDepartureBoardXml: RequestHandler;
|
|
7
12
|
private parseQuery;
|
|
8
13
|
private computeTimeFrom;
|
|
@@ -8,6 +8,8 @@ const dto_1 = require("../../dto");
|
|
|
8
8
|
const MpvnetXmlSerializer_1 = require("../../helpers/MpvnetXmlSerializer");
|
|
9
9
|
const PIDDepartureBoardsModel_1 = require("../../models/PIDDepartureBoardsModel");
|
|
10
10
|
const shared_1 = require("../../../shared");
|
|
11
|
+
const constants_1 = require("../../../shared/constants");
|
|
12
|
+
const GtfsFeedRepository_1 = require("../../../shared/data-access/GtfsFeedRepository");
|
|
11
13
|
const trace_provider_1 = require("@golemio/core/dist/monitoring/opentelemetry/trace-provider");
|
|
12
14
|
const express_validator_1 = require("@golemio/core/dist/shared/express-validator");
|
|
13
15
|
const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
|
|
@@ -20,7 +22,26 @@ class V2DepartureBoardsController {
|
|
|
20
22
|
const timeFrom = this.computeTimeFrom(query, preferredTimezone);
|
|
21
23
|
const span = (0, trace_provider_1.createChildSpan)("V2DepartureBoardsController.getDepartureBoard");
|
|
22
24
|
try {
|
|
23
|
-
const dto = await this.fetchBoard(query, preferredTimezone, timeFrom);
|
|
25
|
+
const dto = await this.fetchBoard(constants_1.PID_FEED_ID, query, preferredTimezone, timeFrom);
|
|
26
|
+
res.status(200).send(dto);
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
next(err);
|
|
30
|
+
}
|
|
31
|
+
finally {
|
|
32
|
+
span?.end();
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Departure board of the feed given by the `feed` query param (a gtfs_feeds.code value), stops by GTFS ids or names
|
|
37
|
+
*/
|
|
38
|
+
this.getFeedDepartureBoard = async (req, res, next) => {
|
|
39
|
+
const { query, preferredTimezone } = this.parseQuery(req);
|
|
40
|
+
const timeFrom = this.computeTimeFrom(query, preferredTimezone);
|
|
41
|
+
const span = (0, trace_provider_1.createChildSpan)("V2DepartureBoardsController.getFeedDepartureBoard");
|
|
42
|
+
try {
|
|
43
|
+
const feedId = await this.feedRepository.getFeedIdByCode((0, express_validator_1.matchedData)(req).feed);
|
|
44
|
+
const dto = await this.fetchBoard(feedId, query, preferredTimezone, timeFrom);
|
|
24
45
|
res.status(200).send(dto);
|
|
25
46
|
}
|
|
26
47
|
catch (err) {
|
|
@@ -39,7 +60,7 @@ class V2DepartureBoardsController {
|
|
|
39
60
|
const timeFrom = this.computeTimeFrom(query, preferredTimezone);
|
|
40
61
|
const span = (0, trace_provider_1.createChildSpan)("V2DepartureBoardsController.getDepartureBoardXml");
|
|
41
62
|
try {
|
|
42
|
-
const dto = await this.fetchBoard(query, preferredTimezone, timeFrom);
|
|
63
|
+
const dto = await this.fetchBoard(constants_1.PID_FEED_ID, query, preferredTimezone, timeFrom);
|
|
43
64
|
res.set("Content-Type", "text/xml; charset=utf-8").status(200).send(MpvnetXmlSerializer_1.MpvnetXmlSerializer.serialize(dto));
|
|
44
65
|
}
|
|
45
66
|
catch (err) {
|
|
@@ -50,6 +71,7 @@ class V2DepartureBoardsController {
|
|
|
50
71
|
}
|
|
51
72
|
};
|
|
52
73
|
this.departureBoardsModel = new PIDDepartureBoardsModel_1.PIDDepartureBoardsModel();
|
|
74
|
+
this.feedRepository = new GtfsFeedRepository_1.GtfsFeedRepository();
|
|
53
75
|
}
|
|
54
76
|
parseQuery(req) {
|
|
55
77
|
const queryData = (0, express_validator_1.matchedData)(req);
|
|
@@ -72,8 +94,9 @@ class V2DepartureBoardsController {
|
|
|
72
94
|
: moment_timezone_1.default.tz(query.timeFrom, preferredTimezone)
|
|
73
95
|
: undefined;
|
|
74
96
|
}
|
|
75
|
-
async fetchBoard(query, preferredTimezone, timeFrom) {
|
|
97
|
+
async fetchBoard(feedId, query, preferredTimezone, timeFrom) {
|
|
76
98
|
const data = await this.departureBoardsModel.getAll({
|
|
99
|
+
feedId,
|
|
77
100
|
aswIds: query.aswIds,
|
|
78
101
|
cisIds: query.cisIds,
|
|
79
102
|
gtfsIds: query.ids,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"V2DepartureBoardsController.js","sourceRoot":"","sources":["../../../../../src/output-gateway/pid/controllers/v2/V2DepartureBoardsController.ts"],"names":[],"mappings":";;;;;;AAAA,mCAAkF;AAClF,2EAA0E;AAC1E,kFAAiF;AACjF,4CAA8C;AAC9C,+FAA6F;AAE7F,mFAA0E;AAC1E,6EAAwE;AACxE,gGAA2E;AAE3E,MAAa,2BAA2B;
|
|
1
|
+
{"version":3,"file":"V2DepartureBoardsController.js","sourceRoot":"","sources":["../../../../../src/output-gateway/pid/controllers/v2/V2DepartureBoardsController.ts"],"names":[],"mappings":";;;;;;AAAA,mCAAkF;AAClF,2EAA0E;AAC1E,kFAAiF;AACjF,4CAA8C;AAC9C,yDAAmD;AACnD,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,UAAU,CACpB,MAAc,EACd,KAA8B,EAC9B,iBAAyB,EACzB,QAA4B;QAE5B,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC;YAChD,MAAM;YACN,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,OAAO,EAAE,KAAK,CAAC,GAAG;YAClB,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,YAAY,EAAE,KAAK,CAAC,YAAY;YAChC,aAAa,EAAE,KAAK,CAAC,aAAa;YAClC,QAAQ;YACR,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK;YACjC,QAAQ,EAAE,iBAAiB;YAC3B,kBAAkB,EAAE,KAAK,CAAC,kBAAkB;YAC5C,YAAY,EAAE,KAAK,CAAC,YAAY;YAChC,oBAAoB,EAAE,KAAK,CAAC,oBAAoB;YAChD,MAAM,EAAE,KAAK,CAAC,MAAM;SACvB,CAAC,CAAC;QACH,OAAO,yBAAgB,CAAC,sBAAsB,CAAC,gCAA0B,EAAE,IAAI,CAAC,CAAC;IACrF,CAAC;CACJ;AA7HD,kEA6HC"}
|
|
@@ -37,7 +37,8 @@ let DeparturesRepository = class DeparturesRepository {
|
|
|
37
37
|
async GetAll(options) {
|
|
38
38
|
const { start, end, canceledStart, canceledEnd } = this.getDepartureTimestamps(options);
|
|
39
39
|
const result = await this.connector.getConnection().query(`
|
|
40
|
-
SELECT * from ${this.schema}.
|
|
40
|
+
SELECT * from ${this.schema}.get_feed_departures(
|
|
41
|
+
$feedid,
|
|
41
42
|
$stopsids,
|
|
42
43
|
$mode,
|
|
43
44
|
$datedeparturebetweenstart,
|
|
@@ -48,6 +49,7 @@ let DeparturesRepository = class DeparturesRepository {
|
|
|
48
49
|
$airconditioninfoenabled);`, {
|
|
49
50
|
type: sequelize_1.QueryTypes.SELECT,
|
|
50
51
|
bind: {
|
|
52
|
+
feedid: options.feedId,
|
|
51
53
|
stopsids: options.stopsIds.join(","),
|
|
52
54
|
mode: options.mode === DepartureMode_1.DepartureMode.ARRIVALS ? 2 : options.mode === DepartureMode_1.DepartureMode.MIXED ? 3 : 1,
|
|
53
55
|
datedeparturebetweenstart: start,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeparturesRepository.js","sourceRoot":"","sources":["../../../../src/output-gateway/pid/data-access/DeparturesRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6DAAuC;AAGvC,wEAAqE;AACrE,6EAAwE;AACxE,mEAAiE;AACjE,iEAAwE;AACxE,kEAA+D;AAK/D,MAAM,oBAAoB,GAAG,KAAK,CAAC;AAG5B,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAI7B,YACiD,SAA6B,EAC1C,MAAqB;QADR,cAAS,GAAT,SAAS,CAAoB;QAG1E,IAAI,CAAC,MAAM,GAAG,iBAAS,CAAC;QACxB,IAAI,CAAC,+BAA+B,GAAG,MAAM,CAAC,UAAU,CAAC,+CAA+C,EAAE,IAAI,CAAC,CAAC;IACpH,CAAC;IAED,MAAM,CAAC,EAAO;QACV,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC/C,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,OAA+B;QACxC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC;QACxF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,CAAC,KAAK,CACrD;4BACgB,IAAI,CAAC,MAAM
|
|
1
|
+
{"version":3,"file":"DeparturesRepository.js","sourceRoot":"","sources":["../../../../src/output-gateway/pid/data-access/DeparturesRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6DAAuC;AAGvC,wEAAqE;AACrE,6EAAwE;AACxE,mEAAiE;AACjE,iEAAwE;AACxE,kEAA+D;AAK/D,MAAM,oBAAoB,GAAG,KAAK,CAAC;AAG5B,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAI7B,YACiD,SAA6B,EAC1C,MAAqB;QADR,cAAS,GAAT,SAAS,CAAoB;QAG1E,IAAI,CAAC,MAAM,GAAG,iBAAS,CAAC;QACxB,IAAI,CAAC,+BAA+B,GAAG,MAAM,CAAC,UAAU,CAAC,+CAA+C,EAAE,IAAI,CAAC,CAAC;IACpH,CAAC;IAED,MAAM,CAAC,EAAO;QACV,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC/C,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,OAA+B;QACxC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC;QACxF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,CAAC,KAAK,CACrD;4BACgB,IAAI,CAAC,MAAM;;;;;;;;;2CASI,EAC/B;YACI,IAAI,EAAE,sBAAU,CAAC,MAAM;YACvB,IAAI,EAAE;gBACF,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC;gBACpC,IAAI,EAAE,OAAO,CAAC,IAAI,KAAK,6BAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,KAAK,6BAAa,CAAC,KAAK,CAAC,C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,iBAAiB,CAAC,CAAA;IACnC,WAAA,IAAA,iBAAM,EAAC,qBAAS,CAAC,YAAY,CAAC,CAAA;;GAN1B,oBAAoB,CAyHhC"}
|
|
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.PIDDepartureBoardsModel = void 0;
|
|
7
|
-
const constants_1 = require("../../shared/constants");
|
|
8
7
|
const StopEnums_1 = require("../../../helpers/StopEnums");
|
|
9
8
|
const data_access_1 = require("../data-access");
|
|
10
9
|
const models_1 = require("../../gtfs/models");
|
|
@@ -54,9 +53,9 @@ class PIDDepartureBoardsModel {
|
|
|
54
53
|
}
|
|
55
54
|
runTuples.add(RunHelper_1.RunHelper.composeRunId(departure.route_id, departure.run_number));
|
|
56
55
|
}
|
|
57
|
-
const { runSchedule, runTripIds } = await this.retrieveAndReturnRunTrips(runTuples);
|
|
56
|
+
const { runSchedule, runTripIds } = await this.retrieveAndReturnRunTrips(options.feedId, runTuples);
|
|
58
57
|
runScheduleMap = runSchedule;
|
|
59
|
-
untrackedTrips = await this.retrieveAndReturnUntrackedTrips(runTripIds);
|
|
58
|
+
untrackedTrips = await this.retrieveAndReturnUntrackedTrips(options.feedId, runTripIds);
|
|
60
59
|
}
|
|
61
60
|
//#endregion
|
|
62
61
|
//#region Processing and returning departures
|
|
@@ -102,6 +101,7 @@ class PIDDepartureBoardsModel {
|
|
|
102
101
|
const stopsToInclude = await models_1.models.GTFSStopModel.GetAll({
|
|
103
102
|
includeMetroTrains: options.includeMetroTrains,
|
|
104
103
|
appendAswId: true,
|
|
104
|
+
feedId: options.feedId,
|
|
105
105
|
aswIds: options.aswIds,
|
|
106
106
|
cisIds: options.cisIds,
|
|
107
107
|
gtfsIds: options.gtfsIds,
|
|
@@ -165,6 +165,7 @@ class PIDDepartureBoardsModel {
|
|
|
165
165
|
try {
|
|
166
166
|
const minutesOffset = options.timeFrom ? options.timeFrom.diff(currentMoment, "minutes") : 0;
|
|
167
167
|
return await this.departuresRepository.GetAll({
|
|
168
|
+
feedId: options.feedId,
|
|
168
169
|
currentMoment,
|
|
169
170
|
minutesAfter: options.minutesAfter,
|
|
170
171
|
minutesBefore: options.minutesBefore,
|
|
@@ -185,13 +186,13 @@ class PIDDepartureBoardsModel {
|
|
|
185
186
|
spanDepartures?.end();
|
|
186
187
|
}
|
|
187
188
|
}
|
|
188
|
-
async retrieveAndReturnRunTrips(runTuples) {
|
|
189
|
+
async retrieveAndReturnRunTrips(feedId, runTuples) {
|
|
189
190
|
const runScheduleMap = new Map();
|
|
190
191
|
const tripIds = new Set();
|
|
191
192
|
const spanRunTrips = (0, trace_provider_1.createChildSpan)("V2PIDRouter.Redis.runTrips");
|
|
192
193
|
try {
|
|
193
194
|
const runTuplesArray = Array.from(runTuples);
|
|
194
|
-
const runSchedule = await this.runTripsRedisRepository.getMultipleSchedule(runTuplesArray);
|
|
195
|
+
const runSchedule = await this.runTripsRedisRepository.getMultipleSchedule(feedId, runTuplesArray);
|
|
195
196
|
for (let i = 0; i < runSchedule.length; i++) {
|
|
196
197
|
const runTrip = runSchedule[i];
|
|
197
198
|
if (runTrip) {
|
|
@@ -221,12 +222,12 @@ class PIDDepartureBoardsModel {
|
|
|
221
222
|
spanRunTrips?.end();
|
|
222
223
|
}
|
|
223
224
|
}
|
|
224
|
-
async retrieveAndReturnUntrackedTrips(tripIds) {
|
|
225
|
+
async retrieveAndReturnUntrackedTrips(feedId, tripIds) {
|
|
225
226
|
let untrackedTrips = new Set();
|
|
226
227
|
const spanUntrackedTrips = (0, trace_provider_1.createChildSpan)("V2PIDRouter.Redis.untrackedTrips");
|
|
227
228
|
try {
|
|
228
229
|
const tripIdsArray = Array.from(tripIds);
|
|
229
|
-
untrackedTrips = await this.positionsRedisRepository.getTripsWithUntrackedVehicles(
|
|
230
|
+
untrackedTrips = await this.positionsRedisRepository.getTripsWithUntrackedVehicles(feedId, tripIdsArray);
|
|
230
231
|
return untrackedTrips;
|
|
231
232
|
}
|
|
232
233
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PIDDepartureBoardsModel.js","sourceRoot":"","sources":["../../../../src/output-gateway/pid/models/PIDDepartureBoardsModel.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"PIDDepartureBoardsModel.js","sourceRoot":"","sources":["../../../../src/output-gateway/pid/models/PIDDepartureBoardsModel.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA0D;AAC1D,gDAA2D;AAG3D,8CAAyC;AAOzC,wEAAqE;AACrE,+FAA6F;AAC7F,6EAA8F;AAC9F,gGAA2E;AAG3E,kEAA+D;AAE/D,kCAA2C;AAC3C,kDAA+C;AAE/C,oFAA6D;AAC7D,mDAAgD;AAEhD,2EAAwE;AAExE,MAAM,eAAe,GAAG,GAAG,CAAC;AAE5B,0EAA0E;AAC1E,sEAAsE;AACtE,MAAM,uBAAuB;IAQzB;QACI,IAAI,CAAC,GAAG,GAAG,mBAAc,CAAC,OAAO,CAAU,qBAAS,CAAC,MAAM,CAAC,CAAC;QAC7D,IAAI,CAAC,8BAA8B,GAAG,IAAI,qDAAyB,EAAE,CAAC;QACtE,IAAI,CAAC,oBAAoB,GAAG,IAAI,kCAAoB,CAChD,mBAAc,CAAC,OAAO,CAAqB,qBAAS,CAAC,iBAAiB,CAAC,EACvE,mBAAc,CAAC,OAAO,CAAgB,qBAAS,CAAC,YAAY,CAAC,CAChE,CAAC;QACF,IAAI,CAAC,uBAAuB,GAAG,mBAAc,CAAC,OAAO,CAA2B,uBAAU,CAAC,uBAAuB,CAAC,CAAC;QACpH,IAAI,CAAC,wBAAwB,GAAG,mBAAc,CAAC,OAAO,CAClD,uBAAU,CAAC,gCAAgC,CAC9C,CAAC;QACF,IAAI,CAAC,cAAc,GAAG,mBAAc,CAAC,OAAO,CAAiB,uBAAU,CAAC,cAAc,CAAC,CAAC;IAC5F,CA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AAU,EAAE,OAAO;aACtB,CAAC;QACN,CAAC;gBAAS,CAAC;YACP,YAAY,EAAE,GAAG,EAAE,CAAC;QACxB,CAAC;IACL,CAAC;IAEO,KAAK,CAAC,+BAA+B,CAAC,MAAc,EAAE,OAAoB;QAC9E,IAAI,cAAc,GAAgB,IAAI,GAAG,EAAE,CAAC;QAC5C,MAAM,kBAAkB,GAAG,IAAA,gCAAe,EAAC,kCAAkC,CAAC,CAAC;QAE/E,IAAI,CAAC;YACD,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACzC,cAAc,GAAG,MAAM,IAAI,CAAC,wBAAwB,CAAC,6BAA6B,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;YACzG,OAAO,cAAc,CAAC;QAC1B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,kBAAkB,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC;YAC3C,IAAI,CAAC,GAAG,CAAC,KAAK,CACV,KAAK;YACL,mCAAmC;YACnC,sIAAsI,CACzI,CAAC;YACF,OAAO,cAAc,CAAC;QAC1B,CAAC;gBAAS,CAAC;YACP,kBAAkB,EAAE,GAAG,EAAE,CAAC;QAC9B,CAAC;IACL,CAAC;CACJ;AAEQ,0DAAuB"}
|
|
@@ -4,6 +4,7 @@ import type { DepartureOrder } from "../../helpers/enums/DepartureOrder";
|
|
|
4
4
|
import type { DepartureSkip } from "../../helpers/enums/DepartureSkip";
|
|
5
5
|
import type { Moment } from "@golemio/core/dist/shared/moment-timezone";
|
|
6
6
|
export interface IGetDeparturesOptions {
|
|
7
|
+
feedId: number;
|
|
7
8
|
aswIds?: string[];
|
|
8
9
|
cisIds?: string[];
|
|
9
10
|
gtfsIds?: string[];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { PublicTransportRouter } from "../../../shared";
|
|
2
|
+
import { Router } from "@golemio/core/dist/shared/express";
|
|
3
|
+
/**
|
|
4
|
+
* Departure boards of any feed, selected by the required `feed` query param (a gtfs_feeds.code value).
|
|
5
|
+
* Stops are identified by GTFS ids or names only; ASW/CIS ids and presets are PID-specific.
|
|
6
|
+
* Mounted at /v1/public-transport/departureboards.
|
|
7
|
+
*/
|
|
8
|
+
export declare class V1DepartureBoardsRouter extends PublicTransportRouter {
|
|
9
|
+
readonly router: Router;
|
|
10
|
+
private cacheHeaderMiddleware;
|
|
11
|
+
private departureBoardsController;
|
|
12
|
+
constructor();
|
|
13
|
+
protected initRoutes: () => void;
|
|
14
|
+
}
|
|
15
|
+
declare const v1DepartureBoardsRouter: V1DepartureBoardsRouter;
|
|
16
|
+
export { v1DepartureBoardsRouter };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.v1DepartureBoardsRouter = exports.V1DepartureBoardsRouter = void 0;
|
|
4
|
+
const V2DepartureBoardsController_1 = require("../../../pid/controllers/v2/V2DepartureBoardsController");
|
|
5
|
+
const ParamValidatorManager_1 = require("../../../pid/helpers/ParamValidatorManager");
|
|
6
|
+
const shared_1 = require("../../../shared");
|
|
7
|
+
const constants_1 = require("../../../shared/constants");
|
|
8
|
+
const Validation_1 = require("@golemio/core/dist/output-gateway/Validation");
|
|
9
|
+
const ioc_1 = require("@golemio/core/dist/output-gateway/ioc");
|
|
10
|
+
const express_1 = require("@golemio/core/dist/shared/express");
|
|
11
|
+
const express_validator_1 = require("@golemio/core/dist/shared/express-validator");
|
|
12
|
+
const const_1 = require("../../../../const");
|
|
13
|
+
/**
|
|
14
|
+
* Departure boards of any feed, selected by the required `feed` query param (a gtfs_feeds.code value).
|
|
15
|
+
* Stops are identified by GTFS ids or names only; ASW/CIS ids and presets are PID-specific.
|
|
16
|
+
* Mounted at /v1/public-transport/departureboards.
|
|
17
|
+
*/
|
|
18
|
+
class V1DepartureBoardsRouter extends shared_1.PublicTransportRouter {
|
|
19
|
+
constructor() {
|
|
20
|
+
super(constants_1.RouteVersion.v1, "departureboards");
|
|
21
|
+
this.router = (0, express_1.Router)();
|
|
22
|
+
this.initRoutes = () => {
|
|
23
|
+
const { preferredTimezone, departureBoards: { departureMode, order, filter, skip }, } = constants_1.ValidationArrays;
|
|
24
|
+
this.router.get("/", [
|
|
25
|
+
(0, express_validator_1.query)("feed").exists().not().isEmpty({ ignore_whitespace: true }).not().isArray(),
|
|
26
|
+
(0, express_validator_1.query)("ids").optional(),
|
|
27
|
+
(0, express_validator_1.query)("names").optional(),
|
|
28
|
+
// at least one of ids or names is required
|
|
29
|
+
(0, express_validator_1.oneOf)([(0, express_validator_1.query)("ids").exists(), (0, express_validator_1.query)("names").exists()]),
|
|
30
|
+
(0, express_validator_1.query)("ids").optional().not().isEmpty({ ignore_whitespace: true }),
|
|
31
|
+
(0, express_validator_1.query)("names").optional().not().isEmpty({ ignore_whitespace: true }),
|
|
32
|
+
(0, express_validator_1.query)("minutesBefore")
|
|
33
|
+
.optional()
|
|
34
|
+
.isInt(process.env.NODE_ENV === "test"
|
|
35
|
+
? {}
|
|
36
|
+
: { lt: const_1.DATA_RETENTION_IN_MINUTES + 1, gt: -1 * (const_1.GTFS_CALENDAR_LIMIT_IN_MINUTES + 1) })
|
|
37
|
+
.not()
|
|
38
|
+
.isArray(),
|
|
39
|
+
(0, express_validator_1.query)("minutesAfter")
|
|
40
|
+
.optional()
|
|
41
|
+
.isInt({
|
|
42
|
+
lt: const_1.GTFS_CALENDAR_LIMIT_IN_MINUTES + 1,
|
|
43
|
+
gt: -1 * (const_1.GTFS_CALENDAR_LIMIT_IN_MINUTES + const_1.DATA_RETENTION_IN_MINUTES + 1),
|
|
44
|
+
})
|
|
45
|
+
.not()
|
|
46
|
+
.isArray(),
|
|
47
|
+
(0, express_validator_1.query)("preferredTimezone").optional().isIn(preferredTimezone).not().isArray(),
|
|
48
|
+
(0, express_validator_1.query)("mode").optional().isIn(departureMode),
|
|
49
|
+
(0, express_validator_1.query)("order").optional().isIn(order).not().isArray(),
|
|
50
|
+
(0, express_validator_1.query)("filter").optional().isIn(filter).not().isArray(),
|
|
51
|
+
(0, express_validator_1.query)("skip").optional().isIn(skip),
|
|
52
|
+
(0, express_validator_1.query)("timeFrom").optional().isISO8601().custom(ParamValidatorManager_1.ParamValidatorManager.getTimeFromValidator()).not().isArray(),
|
|
53
|
+
(0, express_validator_1.query)("total").optional().isInt().not().isArray(),
|
|
54
|
+
(0, express_validator_1.query)("appendHeadsignsLimit").optional().isInt({ min: 0, max: 100 }).not().isArray(),
|
|
55
|
+
], (0, Validation_1.paginationLimitMiddleware)("DepartureBoards"), Validation_1.checkErrors,
|
|
56
|
+
// max-age 5 seconds, stale-while-revalidate 5 seconds
|
|
57
|
+
this.cacheHeaderMiddleware.getMiddleware(5, 5), this.departureBoardsController.getFeedDepartureBoard);
|
|
58
|
+
};
|
|
59
|
+
this.cacheHeaderMiddleware = ioc_1.OutputGatewayContainer.resolve(ioc_1.ContainerToken.CacheHeaderMiddleware);
|
|
60
|
+
this.departureBoardsController = new V2DepartureBoardsController_1.V2DepartureBoardsController();
|
|
61
|
+
this.initRoutes();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.V1DepartureBoardsRouter = V1DepartureBoardsRouter;
|
|
65
|
+
const v1DepartureBoardsRouter = new V1DepartureBoardsRouter();
|
|
66
|
+
exports.v1DepartureBoardsRouter = v1DepartureBoardsRouter;
|
|
67
|
+
//# sourceMappingURL=V1DepartureBoardsRouter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"V1DepartureBoardsRouter.js","sourceRoot":"","sources":["../../../../../src/output-gateway/public/routers/v1/V1DepartureBoardsRouter.ts"],"names":[],"mappings":";;;AAAA,yGAAiG;AACjG,sFAA8E;AAC9E,4CAAmD;AACnD,yDAAsE;AAEtE,6EAAsG;AACtG,+DAA+F;AAC/F,+DAA2D;AAC3D,mFAA2E;AAC3E,6CAAsF;AAEtF;;;;GAIG;AACH,MAAa,uBAAwB,SAA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yBAAK,EAAC,sBAAsB,CAAC,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE;aACvF,EACD,IAAA,sCAAyB,EAAC,iBAAiB,CAAC,EAC5C,wBAAW;YACX,sDAAsD;YACtD,IAAI,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,EAC9C,IAAI,CAAC,yBAAyB,CAAC,qBAAqB,CACvD,CAAC;QACN,CAAC,CAAC;QArDE,IAAI,CAAC,qBAAqB,GAAG,4BAAsB,CAAC,OAAO,CAAwB,oBAAc,CAAC,qBAAqB,CAAC,CAAC;QACzH,IAAI,CAAC,yBAAyB,GAAG,IAAI,yDAA2B,EAAE,CAAC;QACnE,IAAI,CAAC,UAAU,EAAE,CAAC;IACtB,CAAC;CAmDJ;AA7DD,0DA6DC;AAED,MAAM,uBAAuB,GAAG,IAAI,uBAAuB,EAAE,CAAC;AAErD,0DAAuB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IPublicApiDetailedTrip } from "../../../../domain/PublicApiDetailedTripInterfaces";
|
|
2
|
+
import { GTFSStopTimesModel } from "../../../../../gtfs/models/GTFSStopTimesModel";
|
|
2
3
|
import { IDelayComputationRepository } from "../../../../domain/repository/IDelayComputationRepository";
|
|
3
4
|
import { IStopTimeRepository } from "../../../../domain/repository/IStopTimeRepository";
|
|
4
5
|
import { IPublicApiCacheDto } from "../../../../../../schema-definitions/vehicle-positions/redis/interfaces/IPublicApiCacheDto";
|
|
@@ -7,8 +8,10 @@ export declare class StopTimesTripScopeHandler extends AbstractDetailedTripScope
|
|
|
7
8
|
private delayComputationRepository;
|
|
8
9
|
private stopTimeRepository;
|
|
9
10
|
private tripStopTimesTransformation;
|
|
11
|
+
protected stopTimesModel: GTFSStopTimesModel;
|
|
10
12
|
constructor(delayComputationRepository: IDelayComputationRepository, stopTimeRepository: IStopTimeRepository);
|
|
11
13
|
handle(output: IPublicApiDetailedTrip, vehiclePosition: IPublicApiCacheDto): Promise<IPublicApiDetailedTrip>;
|
|
14
|
+
private getScheduledStopTimes;
|
|
12
15
|
private filterNoStopWaypoints;
|
|
13
16
|
private checkStopTimesSequence;
|
|
14
17
|
}
|
package/dist/output-gateway/public/service/helpers/trip-scope/strategy/StopTimesTripScopeHandler.js
CHANGED
|
@@ -13,6 +13,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.StopTimesTripScopeHandler = void 0;
|
|
16
|
+
const models_1 = require("../../../../../gtfs/models");
|
|
16
17
|
const PublicCacheKeys_1 = require("../../../../../../schema-definitions/vehicle-positions/redis/PublicCacheKeys");
|
|
17
18
|
const OgModuleToken_1 = require("../../../../ioc/OgModuleToken");
|
|
18
19
|
const PublicVPTripStopTimesTransformation_1 = require("../../../transformations/scopes/PublicVPTripStopTimesTransformation");
|
|
@@ -26,20 +27,17 @@ let StopTimesTripScopeHandler = class StopTimesTripScopeHandler extends Abstract
|
|
|
26
27
|
this.delayComputationRepository = delayComputationRepository;
|
|
27
28
|
this.stopTimeRepository = stopTimeRepository;
|
|
28
29
|
this.tripStopTimesTransformation = new PublicVPTripStopTimesTransformation_1.PublicVPTripStopTimesTransformation();
|
|
30
|
+
this.stopTimesModel = models_1.models.GTFSStopTimesModel;
|
|
29
31
|
}
|
|
30
32
|
async handle(output, vehiclePosition) {
|
|
31
33
|
// same feed source as DetailedTripFacade: vehicle ids are <feedId>-<feedLocalId>
|
|
32
34
|
const feedId = PublicCacheKeys_1.PublicCacheKeys.feedIdFromVehicleId(vehiclePosition.vehicle_id);
|
|
33
|
-
|
|
34
|
-
? null
|
|
35
|
-
: await this.delayComputationRepository.getDelayComputationCacheProperty(feedId, vehiclePosition.gtfs_trip_id, "stop_times");
|
|
36
|
-
// only CIS/MPV pipelines compute delays (UpdateDelayTask); polled GTFS-RT feeds have none, so the
|
|
37
|
-
// scope is empty instead of failing the whole detail response
|
|
38
|
-
if (!delayComputationCache) {
|
|
35
|
+
if (feedId === null) {
|
|
39
36
|
output.stop_times = (0, Geo_1.buildGeojsonFeatureCollection)([]);
|
|
40
37
|
return output;
|
|
41
38
|
}
|
|
42
|
-
const
|
|
39
|
+
const scheduledStopTimes = await this.getScheduledStopTimes(feedId, vehiclePosition.gtfs_trip_id);
|
|
40
|
+
const filteredStopTimes = this.filterNoStopWaypoints(scheduledStopTimes);
|
|
43
41
|
const vpAndFilteredStopTimes = filteredStopTimes.map((stopTime) => ({ stopTime, vehiclePosition }));
|
|
44
42
|
const stopTimes = this.tripStopTimesTransformation.transformArray(vpAndFilteredStopTimes);
|
|
45
43
|
const stopTimesWithDelay = await this.stopTimeRepository.getPublicStopTimeCache(vehiclePosition.vehicle_id, vehiclePosition.gtfs_trip_id);
|
|
@@ -73,6 +71,15 @@ let StopTimesTripScopeHandler = class StopTimesTripScopeHandler extends Abstract
|
|
|
73
71
|
output.stop_times = (0, Geo_1.buildGeojsonFeatureCollection)(stopTimes);
|
|
74
72
|
return output;
|
|
75
73
|
}
|
|
74
|
+
async getScheduledStopTimes(feedId, gtfsTripId) {
|
|
75
|
+
const delayComputationCache = await this.delayComputationRepository.getDelayComputationCacheProperty(feedId, gtfsTripId, "stop_times");
|
|
76
|
+
if (delayComputationCache) {
|
|
77
|
+
return delayComputationCache.stop_times;
|
|
78
|
+
}
|
|
79
|
+
// only CIS/MPV pipelines compute delays (UpdateDelayTask); polled GTFS-RT feeds have none, so their
|
|
80
|
+
// stop times come straight from the feed's static GTFS
|
|
81
|
+
return this.stopTimesModel.getTripStopTimesWithStops(gtfsTripId, feedId);
|
|
82
|
+
}
|
|
76
83
|
filterNoStopWaypoints(stopTimes) {
|
|
77
84
|
return stopTimes.filter((stopTime) => !stopTime.is_no_stop_waypoint);
|
|
78
85
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StopTimesTripScopeHandler.js","sourceRoot":"","sources":["../../../../../../../src/output-gateway/public/service/helpers/trip-scope/strategy/StopTimesTripScopeHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"StopTimesTripScopeHandler.js","sourceRoot":"","sources":["../../../../../../../src/output-gateway/public/service/helpers/trip-scope/strategy/StopTimesTripScopeHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAIA,uDAAyC;AAGzC,kHAA+E;AAE/E,iEAA6D;AAC7D,6HAAoI;AAGpI,+DAAsF;AAEtF,2DAA2D;AAC3D,iEAAwE;AACxE,yFAAsF;AAG/E,IAAM,yBAAyB,GAA/B,MAAM,yBAA0B,SAAQ,mEAAgC;IAI3E,YAC8D,0BAAuD,EACzD,kBAAuC;QAE/F,KAAK,EAAE,CAAC;QAHkD,+BAA0B,GAA1B,0BAA0B,CAA6B;QACzD,uBAAkB,GAAlB,kBAAkB,CAAqB;QAG/F,IAAI,CAAC,2BAA2B,GAAG,IAAI,yEAAmC,EAAE,CAAC;QAC7E,IAAI,CAAC,cAAc,GAAG,eAAM,CAAC,kBAAkB,CAAC;IACpD,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,MAA8B,EAAE,eAAmC;QACnF,iFAAiF;QACjF,MAAM,MAAM,GAAG,iCAAe,CAAC,mBAAmB,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;QAC/E,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YAClB,MAAM,CAAC,UAAU,GAAG,IAAA,mCAA6B,EAAC,EAAE,CAAC,CAAC;YACtD,OAAO,MAAM,CAAC;QAClB,CAAC;QAED,MAAM,kBAAkB,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,MAAM,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC;QAClG,MAAM,iBAAiB,GAAG,IAAI,CAAC,qBAAqB,CAAC,kBAAkB,CAAC,CAAC;QACzE,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AAqB,EACrB,aAAuB;QAEvB,MAAM,WAAW,GAA2E;YACxF,cAAc,EAAE,SAAS;YACzB,gBAAgB,EAAE,WAAW;SAChC,CAAC;QACF,IAAI,SAAS,GAAG,WAAW,IAAI,aAAa,GAAG,WAAW,IAAI,WAAW,GAAG,WAAW,EAAE,CAAC;YACtF,WAAW,CAAC,gBAAgB,GAAG,IAAI,CAAC;QACxC,CAAC;QACD,IAAI,aAAa,GAAG,SAAS,IAAI,WAAW,GAAG,SAAS,EAAE,CAAC;YACvD,WAAW,CAAC,cAAc,GAAG,IAAI,CAAC;QACtC,CAAC;QACD,OAAO,WAAW,CAAC;IACvB,CAAC;CACJ,CAAA;AAjHY,8DAAyB;oCAAzB,yBAAyB;IADrC,IAAA,qBAAU,GAAE;IAMJ,WAAA,IAAA,iBAAM,EAAC,6BAAa,CAAC,0BAA0B,CAAC,CAAA;IAChD,WAAA,IAAA,iBAAM,EAAC,6BAAa,CAAC,wBAAwB,CAAC,CAAA;;GAN1C,yBAAyB,CAiHrC"}
|
package/docs/follow-ups.md
CHANGED
|
@@ -9,8 +9,8 @@ Resolved and removed so far: gtfs_metadata feed scoping; the OG active endpoints
|
|
|
9
9
|
run numbers; the shapes.txt staging limit (stage ingests the full 193 MB fine; the local dev Redis
|
|
10
10
|
still truncates such files — a local-environment quirk, not a code bug); the destructive-migration
|
|
11
11
|
convention (schema changes now pair the squashed init edit with an incremental migration — see
|
|
12
|
-
CLAUDE.md, first instance `20260820000000-widen-trip-number`); the empty public VP detail `shapes`
|
|
13
|
-
polled GTFS-RT feeds (now read from static GTFS, see #13).
|
|
12
|
+
CLAUDE.md, first instance `20260820000000-widen-trip-number`); the empty public VP detail `shapes` and `stop_times`
|
|
13
|
+
scopes for polled GTFS-RT feeds (now read from static GTFS, see #13).
|
|
14
14
|
|
|
15
15
|
---
|
|
16
16
|
|
|
@@ -202,13 +202,19 @@ own `refreshPublicTripCache {feedCode}` loop under a per-feed mutex; key format
|
|
|
202
202
|
Vehicle ids are `<feedId>-<vehicle>` for every feed so they stay unique across feeds: the stop-time cache keys
|
|
203
203
|
and the detail endpoint (which derives the feed from the id) rely on it. The detail
|
|
204
204
|
`stop_times`/`shapes` scopes read the delay computation of the vehicle's own feed; only the CIS/MPV pipelines
|
|
205
|
-
(`UpdateDelayTask`) write it. Without it,
|
|
206
|
-
`(feed_id, shape_id)
|
|
207
|
-
polled GTFS-RT feeds (fill it from static GTFS by `(feed_id, trip_id)` when a polled feed needs it). A
|
|
205
|
+
(`UpdateDelayTask`) write it. Without it, both scopes fall back to the feed's static GTFS: `shapes` by
|
|
206
|
+
`(feed_id, shape_id)` (raw GTFS points instead of the resampled ones), `stop_times` by `(feed_id, trip_id)`. A
|
|
208
207
|
vehicle without identity in its feed (no registration or CIS number, e.g. polled GTFS-RT) is keyed by its VP
|
|
209
208
|
trip, so it gets a new `vehicle_id` when its trip changes.
|
|
210
209
|
|
|
211
210
|
Left as is:
|
|
211
|
+
- **The static GTFS fallback is not cached**: each detail request of a polled-feed vehicle queries Postgres
|
|
212
|
+
for its shape and stop times (the map polls an open detail every 10 s; the route only sends a 5 s
|
|
213
|
+
`Cache-Control`). Fine at low traffic; when it grows, cache the per-`(feed_id, trip_id)` static data in Redis
|
|
214
|
+
next to the delay computation cache.
|
|
215
|
+
- **Polled-feed `stop_times` carry no realtime times**: `realtime_arrival_time`/`realtime_departure_time` stay
|
|
216
|
+
NULL because the public stop-time cache has no per-stop delays for them (see #12). Projecting the vehicle's
|
|
217
|
+
current `delay` onto the upcoming stops would fill them.
|
|
212
218
|
- **`vehicle_descriptor` scope** joins descriptors by registration number only (see #6).
|
|
213
219
|
- **The public departures / PID departure and transfer boards** read the cache with `PID_FEED_ID`; they need a
|
|
214
220
|
feed parameter before they serve other feeds.
|
|
@@ -1583,6 +1583,18 @@ Worker má na starost stahování VYMI (JIS) událostí a infotextů, jejich tra
|
|
|
1583
1583
|
- načtení souboru z Redis cache
|
|
1584
1584
|
- HGET files:ptGtfsRt alerts.pb
|
|
1585
1585
|
|
|
1586
|
+
### Departure Boards v1
|
|
1587
|
+
|
|
1588
|
+
#### _/v1/public-transport/departureboards_
|
|
1589
|
+
|
|
1590
|
+
- odjezdové tabule libovolného feedu (IDS kraje), feed se volí povinným query parametrem `feed` (kód z `gtfs_feeds`); neznámý feed vrací 404
|
|
1591
|
+
- zastávky se zadávají pouze GTFS `ids` nebo `names` (ASW/CIS id, presety a `airCondition` jsou specifické pro PID)
|
|
1592
|
+
- zdrojová DB funkce `get_feed_departures(feed_id, ...)` – feedově omezená varianta `get_departures` (`trip_id` a `stop_id` jsou unikátní jen v rámci feedu); prázdné `pickup_type`/`drop_off_type` se dle GTFS bere jako běžný nástup/výstup
|
|
1593
|
+
- zdrojové tabulky
|
|
1594
|
+
- `gtfs_precomputed_departures`, `gtfs_stops`, `gtfs_run_numbers`, `vehiclepositions_positions`, `vehiclepositions_trips`, `vehiclepositions_vehicle_descriptors`, `vehiclepositions_cis_stops`, `jis_infotexts`, `departures_directions`
|
|
1595
|
+
- formát odpovědi je shodný s `/v2/pid/departureboards` (bez hlavičky `X-Golemio-Preset-Metadata`)
|
|
1596
|
+
- cachováno na 5 sekund (stale-while-revalidate 5 sekund)
|
|
1597
|
+
|
|
1586
1598
|
### PID Departure Boards v2
|
|
1587
1599
|
|
|
1588
1600
|
> **Vypnuto** – endpoint není v rozsahu modulu public-transport, router je zakomentovaný v `src/output-gateway/index.ts`.
|
package/docs/openapi-output.yaml
CHANGED
|
@@ -46,6 +46,9 @@ tags:
|
|
|
46
46
|
#
|
|
47
47
|
- name: 🕐 Public Vehicle Positions (v2)
|
|
48
48
|
description: Multi-feed live vehicle positions served from cache
|
|
49
|
+
|
|
50
|
+
- name: 🚏 Departure Boards (v1)
|
|
51
|
+
description: <img src="https://img.shields.io/badge/stability-experimental-orange" alt="golemioapi-stability-badge" /> Departure boards of any GTFS feed (IDS region), computed from the feed's timetable and live vehicle positions.
|
|
49
52
|
#
|
|
50
53
|
# - name: 🕒 Public Departures (v2)
|
|
51
54
|
# description: <img src="https://img.shields.io/badge/opendata-available-green" alt="golemioapi-opendata-badge" />
|
|
@@ -964,6 +967,64 @@ paths:
|
|
|
964
967
|
"404":
|
|
965
968
|
description: Not found
|
|
966
969
|
|
|
970
|
+
/v1/public-transport/departureboards:
|
|
971
|
+
get:
|
|
972
|
+
summary: GET Departure Boards
|
|
973
|
+
description: >-
|
|
974
|
+
Departures of the feed given by `feed` (a code from `/v1/public-transport/gtfs/feeds`).
|
|
975
|
+
You have to use query parameters `ids` or `names` in array format - eg. `ids[]=1&ids[]=3`.
|
|
976
|
+
**At least one of them is required.** The maximum is 100 stops combined in one request.
|
|
977
|
+
tags:
|
|
978
|
+
- 🚏 Departure Boards (v1)
|
|
979
|
+
parameters:
|
|
980
|
+
- name: feed
|
|
981
|
+
in: query
|
|
982
|
+
description: GTFS feed code (from the gtfs_feeds registry) whose stops and departures are returned.
|
|
983
|
+
required: true
|
|
984
|
+
schema:
|
|
985
|
+
type: string
|
|
986
|
+
example: "pid"
|
|
987
|
+
- $ref: "#/components/parameters/DepartureBoardsIds"
|
|
988
|
+
- $ref: "#/components/parameters/DepartureBoardsNames"
|
|
989
|
+
- $ref: "#/components/parameters/DepartureBoardsMinutesBefore"
|
|
990
|
+
- $ref: "#/components/parameters/DepartureBoardsMinutesAfter"
|
|
991
|
+
- $ref: "#/components/parameters/DepartureBoardsTimeFrom"
|
|
992
|
+
- $ref: "#/components/parameters/DepartureBoardsPreferredTimezone"
|
|
993
|
+
- name: mode
|
|
994
|
+
in: query
|
|
995
|
+
description: >-
|
|
996
|
+
Valid entries: `departures` (default), `arrivals`, `mixed`. `departures` returns all connections that depart from selected stops (does not return connections for which it is the final stop). `arrivals` returns all connections that arrive into the stops (does not return connections for which it is the first stop). `mixed` returns everything.
|
|
997
|
+
required: false
|
|
998
|
+
schema:
|
|
999
|
+
type: string
|
|
1000
|
+
example: "departures"
|
|
1001
|
+
- $ref: "#/components/parameters/DepartureBoardsOrder"
|
|
1002
|
+
- $ref: "#/components/parameters/DepartureBoardsFilter"
|
|
1003
|
+
- $ref: "#/components/parameters/DepartureBoardsSkip"
|
|
1004
|
+
- $ref: "#/components/parameters/DepartureBoardsLimit"
|
|
1005
|
+
- $ref: "#/components/parameters/DepartureBoardsTotal"
|
|
1006
|
+
- $ref: "#/components/parameters/DepartureBoardsOffset"
|
|
1007
|
+
- $ref: "#/components/parameters/DepartureBoardsAppendHeadsignsLimit"
|
|
1008
|
+
responses:
|
|
1009
|
+
"200":
|
|
1010
|
+
description: Can return empty data in departures property (empty array []) if no departures were found
|
|
1011
|
+
headers:
|
|
1012
|
+
Cache-Control:
|
|
1013
|
+
description: Cache control directive for caching proxies
|
|
1014
|
+
schema:
|
|
1015
|
+
type: string
|
|
1016
|
+
example: public, s-maxage=5, stale-while-revalidate=5
|
|
1017
|
+
content:
|
|
1018
|
+
application/json:
|
|
1019
|
+
schema:
|
|
1020
|
+
$ref: "#/components/schemas/PIDDepartureBoard"
|
|
1021
|
+
"400":
|
|
1022
|
+
description: Invalid query parameters
|
|
1023
|
+
"401":
|
|
1024
|
+
$ref: "#/components/responses/UnauthorizedError"
|
|
1025
|
+
"404":
|
|
1026
|
+
description: Unknown feed or no stops found
|
|
1027
|
+
|
|
967
1028
|
# /v2/pid/departureboards:
|
|
968
1029
|
# get:
|
|
969
1030
|
# summary: GET Departure Boards
|
|
@@ -3355,11 +3416,13 @@ components:
|
|
|
3355
3416
|
properties:
|
|
3356
3417
|
node:
|
|
3357
3418
|
type: number
|
|
3358
|
-
|
|
3419
|
+
nullable: true
|
|
3420
|
+
description: ASW ID of node, null for stops without an ASW id (e.g. feeds other than PID)
|
|
3359
3421
|
example: 100
|
|
3360
3422
|
stop:
|
|
3361
3423
|
type: number
|
|
3362
|
-
|
|
3424
|
+
nullable: true
|
|
3425
|
+
description: Identification of the stop within the node, null for stops without an ASW id
|
|
3363
3426
|
example: 2
|
|
3364
3427
|
required:
|
|
3365
3428
|
- node
|