@golemio/pid 5.12.0 → 5.12.1-dev.2542808115
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/example/00_clear_test_data.sql +2 -1
- package/db/example/23_presets_routes_test_data.sql +10 -0
- package/db/migrations/postgresql/20260504000000-add-off-track-to-future-stop-times.js +53 -0
- package/db/migrations/postgresql/20260506163840-create-presets-routes-table.js +49 -0
- package/db/migrations/postgresql/sqls/20260504000000-add-off-track-to-future-stop-times-down.sql +92 -0
- package/db/migrations/postgresql/sqls/20260504000000-add-off-track-to-future-stop-times-up.sql +97 -0
- package/db/migrations/postgresql/sqls/20260506163840-create-presets-routes-table-down.sql +1 -0
- package/db/migrations/postgresql/sqls/20260506163840-create-presets-routes-table-up.sql +11 -0
- package/dist/integration-engine/jis/repositories/JISInfotextsPresetsRepository.d.ts +10 -1
- package/dist/integration-engine/jis/repositories/JISInfotextsPresetsRepository.js +16 -6
- package/dist/integration-engine/jis/repositories/JISInfotextsPresetsRepository.js.map +1 -1
- package/dist/integration-engine/jis/repositories/JISInfotextsRepository.d.ts +3 -1
- package/dist/integration-engine/jis/repositories/JISInfotextsRepository.js +15 -2
- package/dist/integration-engine/jis/repositories/JISInfotextsRepository.js.map +1 -1
- package/dist/integration-engine/jis/repositories/JISInfotextsRopidGTFSStopsRepository.d.ts +6 -15
- package/dist/integration-engine/jis/repositories/JISInfotextsRopidGTFSStopsRepository.js +12 -20
- package/dist/integration-engine/jis/repositories/JISInfotextsRopidGTFSStopsRepository.js.map +1 -1
- package/dist/integration-engine/jis/repositories/RopidDeparturesPresetsRoutesRepository.d.ts +19 -0
- package/dist/integration-engine/jis/repositories/RopidDeparturesPresetsRoutesRepository.js +107 -0
- package/dist/integration-engine/jis/repositories/RopidDeparturesPresetsRoutesRepository.js.map +1 -0
- package/dist/integration-engine/jis/services/JISInfotextsDataService.d.ts +2 -5
- package/dist/integration-engine/jis/services/JISInfotextsDataService.js +2 -5
- package/dist/integration-engine/jis/services/JISInfotextsDataService.js.map +1 -1
- package/dist/integration-engine/jis/transformations/JISInfotextsTransformation.js +2 -2
- package/dist/integration-engine/jis/transformations/JISInfotextsTransformation.js.map +1 -1
- package/dist/integration-engine/ropid-gtfs/data-access/precomputed/DeparturesRepository.js +3 -0
- package/dist/integration-engine/ropid-gtfs/data-access/precomputed/DeparturesRepository.js.map +1 -1
- package/dist/integration-engine/ropid-gtfs/facade/DeparturePresetsFacade.d.ts +4 -1
- package/dist/integration-engine/ropid-gtfs/facade/DeparturePresetsFacade.js +12 -3
- package/dist/integration-engine/ropid-gtfs/facade/DeparturePresetsFacade.js.map +1 -1
- package/dist/integration-engine/ropid-gtfs/interfaces/IPublicDepartureDto.d.ts +3 -0
- package/dist/integration-engine/ropid-gtfs/ioc/Di.js +2 -0
- package/dist/integration-engine/ropid-gtfs/ioc/Di.js.map +1 -1
- package/dist/integration-engine/ropid-gtfs/ioc/RopidGtfsContainerToken.d.ts +1 -0
- package/dist/integration-engine/ropid-gtfs/ioc/RopidGtfsContainerToken.js +1 -0
- package/dist/integration-engine/ropid-gtfs/ioc/RopidGtfsContainerToken.js.map +1 -1
- package/dist/integration-engine/ropid-gtfs/transformations/PublicDepartureCacheTransformation.js +11 -0
- package/dist/integration-engine/ropid-gtfs/transformations/PublicDepartureCacheTransformation.js.map +1 -1
- package/dist/integration-engine/ropid-gtfs/workers/timetables/tasks/RemapPresetsToGtfsStopsTask.js +1 -0
- package/dist/integration-engine/ropid-gtfs/workers/timetables/tasks/RemapPresetsToGtfsStopsTask.js.map +1 -1
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/data-access/TripsRepository.js +1 -0
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/data-access/TripsRepository.js.map +1 -1
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/helpers/BasePositionsManager.js +1 -1
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/helpers/BasePositionsManager.js.map +1 -1
- package/dist/output-gateway/pid/data-access/RopidDeparturesPresetRepository.d.ts +3 -1
- package/dist/output-gateway/pid/data-access/RopidDeparturesPresetRepository.js +25 -9
- package/dist/output-gateway/pid/data-access/RopidDeparturesPresetRepository.js.map +1 -1
- package/dist/output-gateway/pid/data-access/RopidDeparturesPresetsRoutesRepository.d.ts +13 -0
- package/dist/output-gateway/pid/data-access/RopidDeparturesPresetsRoutesRepository.js +40 -0
- package/dist/output-gateway/pid/data-access/RopidDeparturesPresetsRoutesRepository.js.map +1 -0
- package/dist/output-gateway/pid/domain/DeparturesPresetInterfaces.d.ts +9 -0
- package/dist/output-gateway/pid/ioc/Di.js +2 -0
- package/dist/output-gateway/pid/ioc/Di.js.map +1 -1
- package/dist/output-gateway/pid/ioc/OgPidToken.d.ts +1 -0
- package/dist/output-gateway/pid/ioc/OgPidToken.js +1 -0
- package/dist/output-gateway/pid/ioc/OgPidToken.js.map +1 -1
- package/dist/output-gateway/pid/service/transformations/RopidDeparturesPresetTransformation.js +13 -0
- package/dist/output-gateway/pid/service/transformations/RopidDeparturesPresetTransformation.js.map +1 -1
- package/dist/schema-definitions/jis/datasources/JISInfotextsJsonSchema.js +2 -2
- package/dist/schema-definitions/jis/datasources/JISInfotextsJsonSchema.js.map +1 -1
- package/dist/schema-definitions/jis/datasources/interfaces/IJISInfotext.d.ts +1 -3
- package/dist/schema-definitions/jis/datasources/interfaces/IJISInfotextPreset.d.ts +3 -0
- package/dist/schema-definitions/jis/datasources/interfaces/IJISInfotextPreset.js +3 -0
- package/dist/schema-definitions/jis/datasources/interfaces/IJISInfotextPreset.js.map +1 -0
- package/dist/schema-definitions/jis/datasources/interfaces/index.d.ts +1 -0
- package/dist/schema-definitions/jis/datasources/interfaces/index.js +1 -0
- package/dist/schema-definitions/jis/datasources/interfaces/index.js.map +1 -1
- package/dist/schema-definitions/jis/models/JISInfotextsModel.d.ts +2 -0
- package/dist/schema-definitions/jis/models/JISInfotextsModel.js.map +1 -1
- package/dist/schema-definitions/jis/models/RopidDeparturesPresetsRoutesModel.d.ts +15 -0
- package/dist/schema-definitions/jis/models/RopidDeparturesPresetsRoutesModel.js +57 -0
- package/dist/schema-definitions/jis/models/RopidDeparturesPresetsRoutesModel.js.map +1 -0
- package/dist/schema-definitions/jis/models/interfaces/IPresetsRoutes.d.ts +7 -0
- package/dist/schema-definitions/jis/models/interfaces/IPresetsRoutes.js +3 -0
- package/dist/schema-definitions/jis/models/interfaces/IPresetsRoutes.js.map +1 -0
- package/dist/schema-definitions/jis/models/interfaces/index.d.ts +1 -0
- package/dist/schema-definitions/jis/models/interfaces/index.js +1 -0
- package/dist/schema-definitions/jis/models/interfaces/index.js.map +1 -1
- package/dist/schema-definitions/ropid-departures-presets/RopidDeparturesPresetsOutputSchemas.d.ts +1 -0
- package/dist/schema-definitions/ropid-departures-presets/RopidDeparturesPresetsOutputSchemas.js +1 -0
- package/dist/schema-definitions/ropid-departures-presets/RopidDeparturesPresetsOutputSchemas.js.map +1 -1
- package/dist/schema-definitions/ropid-departures-presets/index.d.ts +1 -0
- package/dist/schema-definitions/ropid-departures-presets/models/RopidDeparturesPresetsModel.d.ts +2 -0
- package/dist/schema-definitions/ropid-departures-presets/models/RopidDeparturesPresetsModel.js.map +1 -1
- package/dist/schema-definitions/ropid-gtfs/redis/interfaces/IPublicGtfsDepartureCacheDto.d.ts +5 -0
- package/dist/schema-definitions/ropid-gtfs/redis/schemas/PublicGtfsDepartureDtoSchema.js +10 -0
- package/dist/schema-definitions/ropid-gtfs/redis/schemas/PublicGtfsDepartureDtoSchema.js.map +1 -1
- package/docs/asyncapi.yaml +16 -5
- package/docs/cache/types/redis.md +4 -0
- package/docs/implementation_documentation.md +2 -2
- package/docs/openapi-input.yaml +14 -3
- package/docs/openapi-output.yaml +19 -0
- package/package.json +7 -7
|
@@ -39,7 +39,8 @@ TRUNCATE
|
|
|
39
39
|
"ropidgtfs_precomputed_minmax_stop_sequences_actual",
|
|
40
40
|
"ropidgtfs_precomputed_departures",
|
|
41
41
|
"ropidgtfs_precomputed_trip_connections",
|
|
42
|
-
"ropid_departures_presets_ropidgtfs_stops"
|
|
42
|
+
"ropid_departures_presets_ropidgtfs_stops",
|
|
43
|
+
"ropid_departures_presets_routes";
|
|
43
44
|
|
|
44
45
|
ALTER SEQUENCE ropid_departures_directions_id_seq RESTART;
|
|
45
46
|
ALTER SEQUENCE ropid_departures_presets_id_seq RESTART;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
INSERT INTO ropid_departures_presets (route_name,api_version,route,url_query_params,note,create_batch_id,created_at,created_by,update_batch_id,updated_at,updated_by,is_testing) VALUES
|
|
3
|
+
('test-routes-repo',2,'/pid/departureboards','aswIds=52_4','test',NULL,now(),NULL,NULL,now(),NULL,false);
|
|
4
|
+
|
|
5
|
+
-- preset_id = 4 (after ids 1,2 from 16_preset_logs.sql and id 3 from 21_ropid_departures_presets_ropidgtfs_stops.sql)
|
|
6
|
+
INSERT INTO ropid_departures_presets_ropidgtfs_stops (preset_id, stop_id, created_at, updated_at) VALUES
|
|
7
|
+
(4,'U52Z4P', now(), now());
|
|
8
|
+
|
|
9
|
+
INSERT INTO ropid_departures_presets_routes (preset_id, stop_id, route_id, route_type, route_short_name, created_at, updated_at) VALUES
|
|
10
|
+
(4,'U52Z4P','L115',3,'115', now(), now());
|
|
@@ -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', '20260504000000-add-off-track-to-future-stop-times-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', '20260504000000-add-off-track-to-future-stop-times-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,49 @@
|
|
|
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
|
+
exports.setup = function(options, seedLink) {
|
|
11
|
+
dbm = options.dbmigrate;
|
|
12
|
+
type = dbm.dataType;
|
|
13
|
+
seed = seedLink;
|
|
14
|
+
Promise = options.Promise;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
exports.up = function(db) {
|
|
18
|
+
var filePath = path.join(__dirname, 'sqls', '20260506163840-create-presets-routes-table-up.sql');
|
|
19
|
+
return new Promise( function( resolve, reject ) {
|
|
20
|
+
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
|
|
21
|
+
if (err) return reject(err);
|
|
22
|
+
console.log('received data: ' + data);
|
|
23
|
+
|
|
24
|
+
resolve(data);
|
|
25
|
+
});
|
|
26
|
+
})
|
|
27
|
+
.then(function(data) {
|
|
28
|
+
return db.runSql(data);
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
exports.down = function(db) {
|
|
33
|
+
var filePath = path.join(__dirname, 'sqls', '20260506163840-create-presets-routes-table-down.sql');
|
|
34
|
+
return new Promise( function( resolve, reject ) {
|
|
35
|
+
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
|
|
36
|
+
if (err) return reject(err);
|
|
37
|
+
console.log('received data: ' + data);
|
|
38
|
+
|
|
39
|
+
resolve(data);
|
|
40
|
+
});
|
|
41
|
+
})
|
|
42
|
+
.then(function(data) {
|
|
43
|
+
return db.runSql(data);
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
exports._meta = {
|
|
48
|
+
"version": 1
|
|
49
|
+
};
|
package/db/migrations/postgresql/sqls/20260504000000-add-off-track-to-future-stop-times-down.sql
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
CREATE OR REPLACE VIEW v_public_vehiclepositions_future_stop_times AS
|
|
2
|
+
WITH RECURSIVE stop_times AS (
|
|
3
|
+
SELECT
|
|
4
|
+
rst.trip_id,
|
|
5
|
+
vt.id AS trips_id,
|
|
6
|
+
vt.provider_source_type,
|
|
7
|
+
coalesce(vp.delay, 0) AS delay,
|
|
8
|
+
coalesce(vp.last_stop_sequence, 1) AS initial_stop_sequence,
|
|
9
|
+
vp.state_position,
|
|
10
|
+
rst.stop_id,
|
|
11
|
+
rst.stop_sequence,
|
|
12
|
+
rst.computed_dwell_time_seconds,
|
|
13
|
+
rst.arrival_time,
|
|
14
|
+
rst.departure_time,
|
|
15
|
+
CASE WHEN vp.last_stop_sequence IS NULL THEN
|
|
16
|
+
coalesce(vp.delay, 0)
|
|
17
|
+
ELSE
|
|
18
|
+
coalesce(vp.delay_stop_arrival, 0)
|
|
19
|
+
END AS arrival_delay_seconds,
|
|
20
|
+
CASE WHEN vp.last_stop_sequence IS NULL THEN
|
|
21
|
+
predict_delay_seconds(vp.delay, rst.computed_dwell_time_seconds, vt.provider_source_type)
|
|
22
|
+
WHEN vp.state_position::text = 'at_stop'::text THEN
|
|
23
|
+
CASE WHEN vt.provider_source_type::text = '1'::text THEN
|
|
24
|
+
greatest(0, vp.delay)
|
|
25
|
+
ELSE
|
|
26
|
+
vp.delay
|
|
27
|
+
END
|
|
28
|
+
ELSE
|
|
29
|
+
vp.delay_stop_departure
|
|
30
|
+
END AS departure_delay_seconds
|
|
31
|
+
FROM
|
|
32
|
+
ropidgtfs_stop_times rst
|
|
33
|
+
JOIN vehiclepositions_trips vt ON vt.gtfs_trip_id::text = rst.trip_id::text
|
|
34
|
+
JOIN vehiclepositions_positions vp ON vp.id = vt.last_position_id
|
|
35
|
+
AND (vp.valid_to IS NULL
|
|
36
|
+
OR vp.valid_to >= now())
|
|
37
|
+
AND (vp.state_position::text = ANY (ARRAY['on_track'::character varying::text,
|
|
38
|
+
'at_stop'::character varying::text,
|
|
39
|
+
'before_track'::character varying::text,
|
|
40
|
+
'before_track_delayed'::character varying::text]))
|
|
41
|
+
WHERE
|
|
42
|
+
vt.gtfs_trip_id IS NOT NULL
|
|
43
|
+
AND rst.stop_sequence = coalesce(vp.last_stop_sequence, 1)
|
|
44
|
+
UNION ALL
|
|
45
|
+
SELECT
|
|
46
|
+
rst.trip_id,
|
|
47
|
+
previous_row.trips_id,
|
|
48
|
+
previous_row.provider_source_type,
|
|
49
|
+
previous_row.delay,
|
|
50
|
+
previous_row.initial_stop_sequence,
|
|
51
|
+
previous_row.state_position,
|
|
52
|
+
rst.stop_id,
|
|
53
|
+
rst.stop_sequence,
|
|
54
|
+
rst.computed_dwell_time_seconds,
|
|
55
|
+
rst.arrival_time,
|
|
56
|
+
rst.departure_time,
|
|
57
|
+
CASE WHEN (rst.stop_sequence - previous_row.initial_stop_sequence) = 1
|
|
58
|
+
AND previous_row.state_position::text <> 'at_stop'::text THEN
|
|
59
|
+
CASE WHEN (rst.arrival_time::interval +(interval '1 second' * previous_row.delay) < previous_row.departure_time::interval +(interval '1 second' *(previous_row.departure_delay_seconds))) THEN
|
|
60
|
+
NULL
|
|
61
|
+
ELSE
|
|
62
|
+
previous_row.delay
|
|
63
|
+
END
|
|
64
|
+
ELSE
|
|
65
|
+
previous_row.departure_delay_seconds
|
|
66
|
+
END AS arrival_delay_seconds,
|
|
67
|
+
predict_delay_seconds(
|
|
68
|
+
CASE WHEN (rst.stop_sequence - previous_row.initial_stop_sequence) = 1
|
|
69
|
+
AND previous_row.state_position::text <> 'at_stop'::text THEN
|
|
70
|
+
previous_row.delay
|
|
71
|
+
ELSE
|
|
72
|
+
previous_row.departure_delay_seconds
|
|
73
|
+
END, rst.computed_dwell_time_seconds, previous_row.provider_source_type) AS departure_delay_seconds
|
|
74
|
+
FROM
|
|
75
|
+
stop_times previous_row
|
|
76
|
+
JOIN ropidgtfs_stop_times rst ON rst.trip_id::text = previous_row.trip_id::text
|
|
77
|
+
AND rst.stop_sequence =(previous_row.stop_sequence + 1))
|
|
78
|
+
SELECT
|
|
79
|
+
stop_times.trips_id AS rt_trip_id,
|
|
80
|
+
stop_times.stop_sequence,
|
|
81
|
+
stop_times.arrival_delay_seconds AS stop_arr_delay,
|
|
82
|
+
CASE WHEN (stop_times.arrival_time::interval +(interval '1 second' * coalesce(stop_times.arrival_delay_seconds, 0))) >(stop_times.departure_time::interval +(interval '1 second' * coalesce(stop_times.departure_delay_seconds, 0))) THEN
|
|
83
|
+
NULL
|
|
84
|
+
ELSE
|
|
85
|
+
stop_times.departure_delay_seconds
|
|
86
|
+
END AS stop_dep_delay,
|
|
87
|
+
stop_times.stop_id
|
|
88
|
+
FROM
|
|
89
|
+
stop_times
|
|
90
|
+
ORDER BY
|
|
91
|
+
stop_times.trip_id,
|
|
92
|
+
stop_times.stop_sequence;
|
package/db/migrations/postgresql/sqls/20260504000000-add-off-track-to-future-stop-times-up.sql
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
CREATE OR REPLACE VIEW v_public_vehiclepositions_future_stop_times AS
|
|
2
|
+
WITH RECURSIVE stop_times AS (
|
|
3
|
+
SELECT
|
|
4
|
+
rst.trip_id,
|
|
5
|
+
vt.id AS trips_id,
|
|
6
|
+
vt.provider_source_type,
|
|
7
|
+
coalesce(vp.delay, 0) AS delay,
|
|
8
|
+
coalesce(vp.last_stop_sequence, 1) AS initial_stop_sequence,
|
|
9
|
+
vp.state_position,
|
|
10
|
+
rst.stop_id,
|
|
11
|
+
rst.stop_sequence,
|
|
12
|
+
rst.computed_dwell_time_seconds,
|
|
13
|
+
rst.arrival_time,
|
|
14
|
+
rst.departure_time,
|
|
15
|
+
CASE WHEN vp.state_position::text = 'off_track'::text THEN
|
|
16
|
+
coalesce(vp.delay, 0)
|
|
17
|
+
WHEN vp.last_stop_sequence IS NULL THEN
|
|
18
|
+
coalesce(vp.delay, 0)
|
|
19
|
+
ELSE
|
|
20
|
+
coalesce(vp.delay_stop_arrival, 0)
|
|
21
|
+
END AS arrival_delay_seconds,
|
|
22
|
+
CASE WHEN vp.state_position::text = 'off_track'::text THEN
|
|
23
|
+
predict_delay_seconds(vp.delay, rst.computed_dwell_time_seconds, vt.provider_source_type)
|
|
24
|
+
WHEN vp.last_stop_sequence IS NULL THEN
|
|
25
|
+
predict_delay_seconds(vp.delay, rst.computed_dwell_time_seconds, vt.provider_source_type)
|
|
26
|
+
WHEN vp.state_position::text = 'at_stop'::text THEN
|
|
27
|
+
CASE WHEN vt.provider_source_type::text = '1'::text THEN
|
|
28
|
+
greatest(0, vp.delay)
|
|
29
|
+
ELSE
|
|
30
|
+
vp.delay
|
|
31
|
+
END
|
|
32
|
+
ELSE
|
|
33
|
+
vp.delay_stop_departure
|
|
34
|
+
END AS departure_delay_seconds
|
|
35
|
+
FROM
|
|
36
|
+
ropidgtfs_stop_times rst
|
|
37
|
+
JOIN vehiclepositions_trips vt ON vt.gtfs_trip_id::text = rst.trip_id::text
|
|
38
|
+
JOIN vehiclepositions_positions vp ON vp.id = vt.last_position_id
|
|
39
|
+
AND (vp.valid_to IS NULL
|
|
40
|
+
OR vp.valid_to >= now())
|
|
41
|
+
AND (vp.state_position::text = ANY (ARRAY['on_track'::character varying::text,
|
|
42
|
+
'at_stop'::character varying::text,
|
|
43
|
+
'before_track'::character varying::text,
|
|
44
|
+
'before_track_delayed'::character varying::text,
|
|
45
|
+
'off_track'::character varying::text]))
|
|
46
|
+
WHERE
|
|
47
|
+
vt.gtfs_trip_id IS NOT NULL
|
|
48
|
+
AND rst.stop_sequence = coalesce(vp.last_stop_sequence, 1)
|
|
49
|
+
UNION ALL
|
|
50
|
+
SELECT
|
|
51
|
+
rst.trip_id,
|
|
52
|
+
previous_row.trips_id,
|
|
53
|
+
previous_row.provider_source_type,
|
|
54
|
+
previous_row.delay,
|
|
55
|
+
previous_row.initial_stop_sequence,
|
|
56
|
+
previous_row.state_position,
|
|
57
|
+
rst.stop_id,
|
|
58
|
+
rst.stop_sequence,
|
|
59
|
+
rst.computed_dwell_time_seconds,
|
|
60
|
+
rst.arrival_time,
|
|
61
|
+
rst.departure_time,
|
|
62
|
+
CASE WHEN (rst.stop_sequence - previous_row.initial_stop_sequence) = 1
|
|
63
|
+
AND previous_row.state_position::text <> 'at_stop'::text THEN
|
|
64
|
+
CASE WHEN (rst.arrival_time::interval +(interval '1 second' * previous_row.delay) < previous_row.departure_time::interval +(interval '1 second' *(previous_row.departure_delay_seconds))) THEN
|
|
65
|
+
NULL
|
|
66
|
+
ELSE
|
|
67
|
+
previous_row.delay
|
|
68
|
+
END
|
|
69
|
+
ELSE
|
|
70
|
+
previous_row.departure_delay_seconds
|
|
71
|
+
END AS arrival_delay_seconds,
|
|
72
|
+
predict_delay_seconds(
|
|
73
|
+
CASE WHEN (rst.stop_sequence - previous_row.initial_stop_sequence) = 1
|
|
74
|
+
AND previous_row.state_position::text <> 'at_stop'::text THEN
|
|
75
|
+
previous_row.delay
|
|
76
|
+
ELSE
|
|
77
|
+
previous_row.departure_delay_seconds
|
|
78
|
+
END, rst.computed_dwell_time_seconds, previous_row.provider_source_type) AS departure_delay_seconds
|
|
79
|
+
FROM
|
|
80
|
+
stop_times previous_row
|
|
81
|
+
JOIN ropidgtfs_stop_times rst ON rst.trip_id::text = previous_row.trip_id::text
|
|
82
|
+
AND rst.stop_sequence =(previous_row.stop_sequence + 1))
|
|
83
|
+
SELECT
|
|
84
|
+
stop_times.trips_id AS rt_trip_id,
|
|
85
|
+
stop_times.stop_sequence,
|
|
86
|
+
stop_times.arrival_delay_seconds AS stop_arr_delay,
|
|
87
|
+
CASE WHEN (stop_times.arrival_time::interval +(interval '1 second' * coalesce(stop_times.arrival_delay_seconds, 0))) >(stop_times.departure_time::interval +(interval '1 second' * coalesce(stop_times.departure_delay_seconds, 0))) THEN
|
|
88
|
+
NULL
|
|
89
|
+
ELSE
|
|
90
|
+
stop_times.departure_delay_seconds
|
|
91
|
+
END AS stop_dep_delay,
|
|
92
|
+
stop_times.stop_id
|
|
93
|
+
FROM
|
|
94
|
+
stop_times
|
|
95
|
+
ORDER BY
|
|
96
|
+
stop_times.trip_id,
|
|
97
|
+
stop_times.stop_sequence;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
drop table pid.ropid_departures_presets_routes;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
create table pid.ropid_departures_presets_routes (
|
|
2
|
+
preset_id integer not null,
|
|
3
|
+
stop_id varchar(50) not null,
|
|
4
|
+
route_id varchar(50) not null,
|
|
5
|
+
route_type smallint not null,
|
|
6
|
+
route_short_name varchar(50) not null,
|
|
7
|
+
created_at timestamptz not null,
|
|
8
|
+
updated_at timestamptz not null,
|
|
9
|
+
constraint ropid_departures_presets_routes_pk primary key (preset_id, stop_id, route_id)
|
|
10
|
+
);
|
|
11
|
+
create index ropid_departures_presets_routes_preset_id_idx on pid.ropid_departures_presets_routes (preset_id);
|
|
@@ -9,13 +9,22 @@ type RepositoryOptions = {
|
|
|
9
9
|
transaction?: Transaction;
|
|
10
10
|
};
|
|
11
11
|
export declare class JISInfotextsPresetsRepository extends AbstractValidatableRepository {
|
|
12
|
-
private logger;
|
|
13
12
|
validator: JSONSchemaValidator;
|
|
14
13
|
schema: string;
|
|
15
14
|
tableName: string;
|
|
16
15
|
private sequelizeModel;
|
|
17
16
|
constructor(connector: IDatabaseConnector, logger: ILogger);
|
|
17
|
+
/**
|
|
18
|
+
* Inserts new rows or updates existing ones. On conflict, all columns except `created_at` are overwritten —
|
|
19
|
+
* `created_at` is intentionally preserved to track when a row was first seen, while `updated_at` advances
|
|
20
|
+
* each cycle so stale-record cleanup can identify entries missing from the latest feed.
|
|
21
|
+
*/
|
|
18
22
|
upsertAll(data: IJISInfotextsPresets[], options?: RepositoryOptions): ReturnType<ModelStatic<JISInfotextsPresetsModel>["bulkCreate"]>;
|
|
23
|
+
/**
|
|
24
|
+
* Removes rows that were not touched during the current refresh cycle — any row whose `updated_at`
|
|
25
|
+
* predates `dateTime` was absent from the latest feed and is considered stale.
|
|
26
|
+
* Call this after `upsertAll` with the timestamp captured at the start of the save to clean up vanished entries.
|
|
27
|
+
*/
|
|
19
28
|
deleteAllLastUpdatedBefore(dateTime: Date, options?: RepositoryOptions): Promise<number>;
|
|
20
29
|
deleteAll(options?: RepositoryOptions): Promise<number>;
|
|
21
30
|
private getUpdateAttributes;
|
|
@@ -17,7 +17,6 @@ const const_1 = require("../../../schema-definitions/const");
|
|
|
17
17
|
const JISInfotextsPresetsModel_1 = require("../../../schema-definitions/jis/models/JISInfotextsPresetsModel");
|
|
18
18
|
const AbstractValidatableRepository_1 = require("@golemio/core/dist/helpers/data-access/postgres/repositories/AbstractValidatableRepository");
|
|
19
19
|
const CoreToken_1 = require("@golemio/core/dist/helpers/ioc/CoreToken");
|
|
20
|
-
const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
|
|
21
20
|
const golemio_validator_1 = require("@golemio/core/dist/shared/golemio-validator");
|
|
22
21
|
const sequelize_1 = require("@golemio/core/dist/shared/sequelize");
|
|
23
22
|
const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
|
|
@@ -25,7 +24,6 @@ const RepositoryUtils_1 = require("../../shared/RepositoryUtils");
|
|
|
25
24
|
let JISInfotextsPresetsRepository = class JISInfotextsPresetsRepository extends AbstractValidatableRepository_1.AbstractValidatableRepository {
|
|
26
25
|
constructor(connector, logger) {
|
|
27
26
|
super(connector, logger);
|
|
28
|
-
this.logger = logger;
|
|
29
27
|
this.schema = const_1.PG_SCHEMA;
|
|
30
28
|
this.tableName = JISInfotextsPresetsModel_1.JISInfotextsPresetsModel.tableName;
|
|
31
29
|
this.validator = new golemio_validator_1.JSONSchemaValidator("JISInfotextsPresetsRepository", JISInfotextsPresetsModel_1.JISInfotextsPresetsModel.jsonSchema);
|
|
@@ -33,6 +31,11 @@ let JISInfotextsPresetsRepository = class JISInfotextsPresetsRepository extends
|
|
|
33
31
|
.getConnection()
|
|
34
32
|
.define(this.tableName, JISInfotextsPresetsModel_1.JISInfotextsPresetsModel.attributeModel, { schema: this.schema });
|
|
35
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Inserts new rows or updates existing ones. On conflict, all columns except `created_at` are overwritten —
|
|
36
|
+
* `created_at` is intentionally preserved to track when a row was first seen, while `updated_at` advances
|
|
37
|
+
* each cycle so stale-record cleanup can identify entries missing from the latest feed.
|
|
38
|
+
*/
|
|
36
39
|
async upsertAll(data, options) {
|
|
37
40
|
try {
|
|
38
41
|
return await this.sequelizeModel.bulkCreate(data, {
|
|
@@ -41,9 +44,14 @@ let JISInfotextsPresetsRepository = class JISInfotextsPresetsRepository extends
|
|
|
41
44
|
});
|
|
42
45
|
}
|
|
43
46
|
catch (err) {
|
|
44
|
-
RepositoryUtils_1.RepositoryUtils.mapSequelizeError(err, this.constructor.name, "upsertAll");
|
|
47
|
+
throw RepositoryUtils_1.RepositoryUtils.mapSequelizeError(err, this.constructor.name, "upsertAll");
|
|
45
48
|
}
|
|
46
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Removes rows that were not touched during the current refresh cycle — any row whose `updated_at`
|
|
52
|
+
* predates `dateTime` was absent from the latest feed and is considered stale.
|
|
53
|
+
* Call this after `upsertAll` with the timestamp captured at the start of the save to clean up vanished entries.
|
|
54
|
+
*/
|
|
47
55
|
async deleteAllLastUpdatedBefore(dateTime, options) {
|
|
48
56
|
try {
|
|
49
57
|
return await this.sequelizeModel.destroy({
|
|
@@ -54,7 +62,7 @@ let JISInfotextsPresetsRepository = class JISInfotextsPresetsRepository extends
|
|
|
54
62
|
});
|
|
55
63
|
}
|
|
56
64
|
catch (err) {
|
|
57
|
-
throw
|
|
65
|
+
throw RepositoryUtils_1.RepositoryUtils.mapSequelizeError(err, this.constructor.name, "deleteAllLastUpdatedBefore");
|
|
58
66
|
}
|
|
59
67
|
}
|
|
60
68
|
async deleteAll(options) {
|
|
@@ -62,11 +70,13 @@ let JISInfotextsPresetsRepository = class JISInfotextsPresetsRepository extends
|
|
|
62
70
|
return await this.sequelizeModel.destroy({ where: {}, transaction: options?.transaction });
|
|
63
71
|
}
|
|
64
72
|
catch (err) {
|
|
65
|
-
throw
|
|
73
|
+
throw RepositoryUtils_1.RepositoryUtils.mapSequelizeError(err, this.constructor.name, "deleteAll");
|
|
66
74
|
}
|
|
67
75
|
}
|
|
76
|
+
// created_at is excluded so that re-upserting an existing row doesn't overwrite
|
|
77
|
+
// when it was first seen — only updated_at should advance on subsequent refreshes.
|
|
68
78
|
getUpdateAttributes() {
|
|
69
|
-
return Object.keys(JISInfotextsPresetsModel_1.JISInfotextsPresetsModel.attributeModel).filter((attribute) =>
|
|
79
|
+
return Object.keys(JISInfotextsPresetsModel_1.JISInfotextsPresetsModel.attributeModel).filter((attribute) => attribute !== "created_at");
|
|
70
80
|
}
|
|
71
81
|
};
|
|
72
82
|
exports.JISInfotextsPresetsRepository = JISInfotextsPresetsRepository;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JISInfotextsPresetsRepository.js","sourceRoot":"","sources":["../../../../src/integration-engine/jis/repositories/JISInfotextsPresetsRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6DAAuC;AACvC,8GAAoF;AAIpF,8IAA2I;AAC3I,wEAAqE;AACrE,
|
|
1
|
+
{"version":3,"file":"JISInfotextsPresetsRepository.js","sourceRoot":"","sources":["../../../../src/integration-engine/jis/repositories/JISInfotextsPresetsRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6DAAuC;AACvC,8GAAoF;AAIpF,8IAA2I;AAC3I,wEAAqE;AACrE,mFAAkF;AAClF,mEAAmF;AACnF,iEAAwE;AACxE,kEAA6D;AAOtD,IAAM,6BAA6B,GAAnC,MAAM,6BAA8B,SAAQ,6DAA6B;IAO5E,YAAiD,SAA6B,EAA4B,MAAe;QACrH,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QANtB,WAAM,GAAG,iBAAS,CAAC;QACnB,cAAS,GAAG,mDAAwB,CAAC,SAAS,CAAC;QAMlD,IAAI,CAAC,SAAS,GAAG,IAAI,uCAAmB,CAAC,+BAA+B,EAAE,mDAAwB,CAAC,UAAU,CAAC,CAAC;QAC/G,IAAI,CAAC,cAAc,GAAG,SAAS;aAC1B,aAAa,EAAE;aACf,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,mDAAwB,CAAC,cAAc,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IAClG,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,SAAS,CAClB,IAA4B,EAC5B,OAA2B;QAE3B,IAAI,CA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AI,CAAC,mDAAwB,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,KAAK,YAAY,CAAC,CAAC;IAClH,CAAC;CACJ,CAAA;AAjEY,sEAA6B;wCAA7B,6BAA6B;IADzC,IAAA,qBAAU,GAAE;IAQI,WAAA,IAAA,iBAAM,EAAC,qBAAS,CAAC,iBAAiB,CAAC,CAAA;IAAiC,WAAA,IAAA,iBAAM,EAAC,qBAAS,CAAC,MAAM,CAAC,CAAA;;GAPhG,6BAA6B,CAiEzC"}
|
|
@@ -6,6 +6,7 @@ import { IDatabaseConnector } from "@golemio/core/dist/helpers/data-access/postg
|
|
|
6
6
|
import { AbstractValidatableRepository } from "@golemio/core/dist/helpers/data-access/postgres/repositories/AbstractValidatableRepository";
|
|
7
7
|
import { JSONSchemaValidator } from "@golemio/core/dist/shared/golemio-validator";
|
|
8
8
|
import { Transaction } from "@golemio/core/dist/shared/sequelize";
|
|
9
|
+
import { JISInfotextsPresetsRepository } from "./JISInfotextsPresetsRepository";
|
|
9
10
|
import { JISInfotextsRopidGTFSStopsRepository } from "./JISInfotextsRopidGTFSStopsRepository";
|
|
10
11
|
type RepositoryOptions = {
|
|
11
12
|
transaction?: Transaction;
|
|
@@ -13,12 +14,13 @@ type RepositoryOptions = {
|
|
|
13
14
|
export declare class JISInfotextsRepository extends AbstractValidatableRepository {
|
|
14
15
|
private logger;
|
|
15
16
|
private infotextStopRepository;
|
|
17
|
+
private infotextPresetsRepository;
|
|
16
18
|
private gtfsStopRepository;
|
|
17
19
|
validator: JSONSchemaValidator;
|
|
18
20
|
schema: string;
|
|
19
21
|
tableName: string;
|
|
20
22
|
private sequelizeModel;
|
|
21
|
-
constructor(connector: IDatabaseConnector, logger: ILogger, infotextStopRepository: JISInfotextsRopidGTFSStopsRepository, gtfsStopRepository: RopidGTFSStopsModel);
|
|
23
|
+
constructor(connector: IDatabaseConnector, logger: ILogger, infotextStopRepository: JISInfotextsRopidGTFSStopsRepository, infotextPresetsRepository: JISInfotextsPresetsRepository, gtfsStopRepository: RopidGTFSStopsModel);
|
|
22
24
|
/**
|
|
23
25
|
* Refresh all data from VYMI and delete old data
|
|
24
26
|
*
|
|
@@ -24,12 +24,14 @@ const sequelize_1 = require("@golemio/core/dist/shared/sequelize");
|
|
|
24
24
|
const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
|
|
25
25
|
const RepositoryUtils_1 = require("../../shared/RepositoryUtils");
|
|
26
26
|
const JISContainerToken_1 = require("../ioc/JISContainerToken");
|
|
27
|
+
const JISInfotextsPresetsRepository_1 = require("./JISInfotextsPresetsRepository");
|
|
27
28
|
const JISInfotextsRopidGTFSStopsRepository_1 = require("./JISInfotextsRopidGTFSStopsRepository");
|
|
28
29
|
let JISInfotextsRepository = class JISInfotextsRepository extends AbstractValidatableRepository_1.AbstractValidatableRepository {
|
|
29
|
-
constructor(connector, logger, infotextStopRepository, gtfsStopRepository) {
|
|
30
|
+
constructor(connector, logger, infotextStopRepository, infotextPresetsRepository, gtfsStopRepository) {
|
|
30
31
|
super(connector, logger);
|
|
31
32
|
this.logger = logger;
|
|
32
33
|
this.infotextStopRepository = infotextStopRepository;
|
|
34
|
+
this.infotextPresetsRepository = infotextPresetsRepository;
|
|
33
35
|
this.gtfsStopRepository = gtfsStopRepository;
|
|
34
36
|
this.schema = const_1.PG_SCHEMA;
|
|
35
37
|
this.tableName = JISInfotextsModel_1.JISInfotextsModel.tableName;
|
|
@@ -64,6 +66,15 @@ let JISInfotextsRepository = class JISInfotextsRepository extends AbstractValida
|
|
|
64
66
|
sourceKey: "stop_id",
|
|
65
67
|
foreignKey: "stop_id",
|
|
66
68
|
});
|
|
69
|
+
this.sequelizeModel.hasMany(this.infotextPresetsRepository["sequelizeModel"], {
|
|
70
|
+
sourceKey: "id",
|
|
71
|
+
foreignKey: "infotext_id",
|
|
72
|
+
as: "presets",
|
|
73
|
+
});
|
|
74
|
+
this.infotextPresetsRepository["sequelizeModel"].belongsTo(this.sequelizeModel, {
|
|
75
|
+
targetKey: "id",
|
|
76
|
+
foreignKey: "infotext_id",
|
|
77
|
+
});
|
|
67
78
|
}
|
|
68
79
|
/**
|
|
69
80
|
* Refresh all data from VYMI and delete old data
|
|
@@ -146,8 +157,10 @@ exports.JISInfotextsRepository = JISInfotextsRepository = __decorate([
|
|
|
146
157
|
__param(0, (0, tsyringe_1.inject)(CoreToken_1.CoreToken.PostgresConnector)),
|
|
147
158
|
__param(1, (0, tsyringe_1.inject)(CoreToken_1.CoreToken.Logger)),
|
|
148
159
|
__param(2, (0, tsyringe_1.inject)(JISContainerToken_1.JISContainerToken.JISInfotextsRopidGTFSStopsRepository)),
|
|
149
|
-
__param(3, (0, tsyringe_1.inject)(JISContainerToken_1.JISContainerToken.
|
|
160
|
+
__param(3, (0, tsyringe_1.inject)(JISContainerToken_1.JISContainerToken.JISInfotextsPresetsRepository)),
|
|
161
|
+
__param(4, (0, tsyringe_1.inject)(JISContainerToken_1.JISContainerToken.RopidGTFSStopsRepository)),
|
|
150
162
|
__metadata("design:paramtypes", [Object, Object, JISInfotextsRopidGTFSStopsRepository_1.JISInfotextsRopidGTFSStopsRepository,
|
|
163
|
+
JISInfotextsPresetsRepository_1.JISInfotextsPresetsRepository,
|
|
151
164
|
ropid_gtfs_1.RopidGTFSStopsModel])
|
|
152
165
|
], JISInfotextsRepository);
|
|
153
166
|
//# sourceMappingURL=JISInfotextsRepository.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JISInfotextsRepository.js","sourceRoot":"","sources":["../../../../src/integration-engine/jis/repositories/JISInfotextsRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,iDAAqD;AACrD,6DAAuC;AACvC,gGAAsE;AAItE,8IAA2I;AAC3I,wEAAqE;AACrE,6EAAwE;AACxE,mFAAkF;AAClF,mEAAmF;AACnF,iEAAwE;AACxE,kEAA6D;AAC7D,gEAA6D;AAC7D,iGAA8F;AAOvF,IAAM,sBAAsB,GAA5B,MAAM,sBAAuB,SAAQ,6DAA6B;IAOrE,YACyC,SAA6B,EACxC,MAAuB,EAEjD,sBAAoE,EAEpE,kBAA+C;QAE/C,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"JISInfotextsRepository.js","sourceRoot":"","sources":["../../../../src/integration-engine/jis/repositories/JISInfotextsRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,iDAAqD;AACrD,6DAAuC;AACvC,gGAAsE;AAItE,8IAA2I;AAC3I,wEAAqE;AACrE,6EAAwE;AACxE,mFAAkF;AAClF,mEAAmF;AACnF,iEAAwE;AACxE,kEAA6D;AAC7D,gEAA6D;AAC7D,mFAAgF;AAChF,iGAA8F;AAOvF,IAAM,sBAAsB,GAA5B,MAAM,sBAAuB,SAAQ,6DAA6B;IAOrE,YACyC,SAA6B,EACxC,MAAuB,EAEjD,sBAAoE,EAEpE,yBAAgE,EAEhE,kBAA+C;QAE/C,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QARS,WAAM,GAAN,MAAM,CAAS;QAEzC,2BAAsB,GAAtB,sBAAsB,CAAsC;QAE5D,8BAAyB,GAAzB,yBAAyB,CAA+B;QAExD,uBAAkB,GAAlB,kBAAkB,CAAqB;QAb5C,WAAM,GAAG,iBAAS,CAAC;QACnB,cAAS,GAAG,qCAAiB,CAAC,SAAS,CAAC;QAe3C,IAAI,CAAC,SAAS,GAAG,IAAI,uCAAmB,CAAC,wBAAwB,EAAE,qCAAiB,CAAC,UAAU,CAAC,CAAC;QACjG,IAAI,CAAC,cAAc,GAAG,SAAS;aAC1B,aAAa,EAAE;aACf,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,qCAAiB,CAAC,cAAc,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QAEvF,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,IAAI,CAAC,kBAAkB,CAAC,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;IACL,CAAC;IACM,KAAK,CAAC,OAAO;QAChB,OAAO,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;YACrC,OAAO,EAAE;gBACL;oBACI,KAAK,EAAE,IAAI,CAAC,kBAAkB,CAAC,cAAc;oBAC7C,EAAE,EAAE,OAAO;oBACX,UAAU,EAAE,CAAC,SAAS,CAAC;oBACvB,OAAO,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE;oBAC3B,QAAQ,EAAE,IAAI;iBACjB;aACJ;SACJ,CAAC,CAAC;IACP,CAAC;CACJ,CAAA;AAhJY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,qBAAU,GAAE;IASJ,WAAA,IAAA,iBAAM,EAAC,qBAAS,CAAC,iBAAiB,CAAC,CAAA;IACnC,WAAA,IAAA,iBAAM,EAAC,qBAAS,CAAC,MAAM,CAAC,CAAA;IACxB,WAAA,IAAA,iBAAM,EAAC,qCAAiB,CAAC,oCAAoC,CAAC,CAAA;IAE9D,WAAA,IAAA,iBAAM,EAAC,qCAAiB,CAAC,6BAA6B,CAAC,CAAA;IAEvD,WAAA,IAAA,iBAAM,EAAC,qCAAiB,CAAC,wBAAwB,CAAC,CAAA;qDAHnB,2EAAoC;QAEjC,6DAA6B;QAEpC,gCAAmB;GAf1C,sBAAsB,CAgJlC"}
|
|
@@ -9,33 +9,24 @@ type RepositoryOptions = {
|
|
|
9
9
|
transaction?: Transaction;
|
|
10
10
|
};
|
|
11
11
|
export declare class JISInfotextsRopidGTFSStopsRepository extends AbstractValidatableRepository {
|
|
12
|
-
private logger;
|
|
13
12
|
validator: JSONSchemaValidator;
|
|
14
13
|
schema: string;
|
|
15
14
|
tableName: string;
|
|
16
15
|
private sequelizeModel;
|
|
17
16
|
constructor(connector: IDatabaseConnector, logger: ILogger);
|
|
18
17
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* @param options Options for the operation
|
|
23
|
-
* @returns The number of deleted items
|
|
18
|
+
* Removes rows that were not touched during the current refresh cycle — any row whose `updated_at`
|
|
19
|
+
* predates `dateTime` was absent from the latest feed and is considered stale.
|
|
20
|
+
* Call this after `upsertAll` with the timestamp captured at the start of the save to clean up vanished entries.
|
|
24
21
|
*/
|
|
25
22
|
deleteAllLastUpdatedBefore(dateTime: Date, options?: RepositoryOptions): Promise<number>;
|
|
26
23
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* @param options Options for the operation
|
|
31
|
-
* @returns The upserted items
|
|
24
|
+
* Inserts new rows or updates existing ones. On conflict, all columns except `created_at` are overwritten —
|
|
25
|
+
* `created_at` is intentionally preserved to track when a row was first seen, while `updated_at` advances
|
|
26
|
+
* each cycle so stale-record cleanup can identify entries missing from the latest feed.
|
|
32
27
|
*/
|
|
33
28
|
upsertAll(data: IJISInfotextsRopidGTFSStops[], options?: RepositoryOptions): ReturnType<ModelStatic<JISInfotextsRopidGTFSStopsModel>["bulkCreate"]>;
|
|
34
29
|
private getUpdateAttributes;
|
|
35
|
-
/**
|
|
36
|
-
* @param options
|
|
37
|
-
* @returns The number of deleted items
|
|
38
|
-
*/
|
|
39
30
|
deleteAll(options?: RepositoryOptions): Promise<number>;
|
|
40
31
|
}
|
|
41
32
|
export {};
|