@golemio/pid 3.5.2 → 3.5.3-dev.1636796644
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/20250103092631-skip-missing.js +53 -0
- package/db/migrations/postgresql/20250109122504-braking-down-mapping-queries.js +53 -0
- package/db/migrations/postgresql/sqls/20250103092631-skip-missing-down.sql +184 -0
- package/db/migrations/postgresql/sqls/20250103092631-skip-missing-up.sql +195 -0
- package/db/migrations/postgresql/sqls/20250109122504-braking-down-mapping-queries-down.sql +12 -0
- package/db/migrations/postgresql/sqls/20250109122504-braking-down-mapping-queries-up.sql +139 -0
- package/dist/integration-engine/ropid-gtfs/data-access/cache/RunTripsRedisRepository.js +2 -1
- package/dist/integration-engine/ropid-gtfs/data-access/cache/RunTripsRedisRepository.js.map +1 -1
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/data-access/TripsRepository.js +6 -5
- 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/data-access/helpers/RawQueryProvider.d.ts +1 -1
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/data-access/helpers/RawQueryProvider.js +101 -165
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/data-access/helpers/RawQueryProvider.js.map +1 -1
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/tasks/PropagateTrainDelayTask.js.map +1 -1
- package/dist/output-gateway/pid/controllers/v2/V2DepartureBoardsController.js +1 -3
- package/dist/output-gateway/pid/controllers/v2/V2DepartureBoardsController.js.map +1 -1
- package/dist/output-gateway/pid/domain/DepartureInterfaces.d.ts +7 -0
- package/dist/output-gateway/pid/domain/DepartureInterfaces.js +3 -0
- package/dist/output-gateway/pid/domain/DepartureInterfaces.js.map +1 -0
- package/dist/output-gateway/pid/index.d.ts +4 -5
- package/dist/output-gateway/pid/index.js +1 -0
- package/dist/output-gateway/pid/index.js.map +1 -1
- package/dist/output-gateway/pid/ioc/Di.js +4 -0
- package/dist/output-gateway/pid/ioc/Di.js.map +1 -1
- package/dist/output-gateway/pid/ioc/OgPidToken.d.ts +2 -0
- package/dist/output-gateway/pid/ioc/OgPidToken.js +2 -0
- package/dist/output-gateway/pid/ioc/OgPidToken.js.map +1 -1
- package/dist/output-gateway/pid/models/PIDDepartureBoardsModel.d.ts +14 -28
- package/dist/output-gateway/pid/models/PIDDepartureBoardsModel.js +192 -72
- package/dist/output-gateway/pid/models/PIDDepartureBoardsModel.js.map +1 -1
- package/dist/output-gateway/pid/models/helpers/PIDDepartureModel.js +26 -15
- package/dist/output-gateway/pid/models/helpers/PIDDepartureModel.js.map +1 -1
- package/dist/output-gateway/pid/models/helpers/SkipHelper.d.ts +11 -0
- package/dist/output-gateway/pid/models/helpers/SkipHelper.js +91 -0
- package/dist/output-gateway/pid/models/helpers/SkipHelper.js.map +1 -1
- package/dist/output-gateway/pid/models/helpers/const.d.ts +4 -0
- package/dist/output-gateway/pid/models/helpers/const.js +8 -0
- package/dist/output-gateway/pid/models/helpers/const.js.map +1 -0
- package/dist/output-gateway/pid/models/helpers/interfaces/IPIDDepartureQueryOptions.d.ts +3 -0
- package/dist/output-gateway/pid/models/interfaces/IGetDeparturesOptions.d.ts +21 -0
- package/dist/output-gateway/pid/models/interfaces/IGetDeparturesOptions.js +3 -0
- package/dist/output-gateway/pid/models/interfaces/IGetDeparturesOptions.js.map +1 -0
- package/dist/output-gateway/pid/service/facade/TransferFacade.js +2 -0
- package/dist/output-gateway/pid/service/facade/TransferFacade.js.map +1 -1
- package/dist/output-gateway/public/data-access/redis/PublicVehiclePositionsRepository.d.ts +4 -2
- package/dist/output-gateway/public/data-access/redis/PublicVehiclePositionsRepository.js +90 -68
- package/dist/output-gateway/public/data-access/redis/PublicVehiclePositionsRepository.js.map +1 -1
- package/dist/output-gateway/public/domain/repository/IVehiclePositionsRepository.d.ts +2 -1
- package/dist/output-gateway/ropid-gtfs/data-access/redis/RunTripsRedisRepository.d.ts +10 -0
- package/dist/output-gateway/ropid-gtfs/data-access/redis/RunTripsRedisRepository.js +65 -0
- package/dist/output-gateway/ropid-gtfs/data-access/redis/RunTripsRedisRepository.js.map +1 -0
- package/dist/output-gateway/ropid-gtfs/domain/repository/IRunTripsRedisRepository.d.ts +4 -0
- package/dist/output-gateway/ropid-gtfs/domain/repository/IRunTripsRedisRepository.js +3 -0
- package/dist/output-gateway/ropid-gtfs/domain/repository/IRunTripsRedisRepository.js.map +1 -0
- package/dist/output-gateway/shared/constants/validations.js +1 -1
- package/dist/output-gateway/shared/constants/validations.js.map +1 -1
- package/dist/schema-definitions/ropid-gtfs/redis/const.d.ts +1 -0
- package/dist/schema-definitions/ropid-gtfs/redis/const.js +2 -1
- package/dist/schema-definitions/ropid-gtfs/redis/const.js.map +1 -1
- package/docs/openapi-output.yaml +10 -2
- package/package.json +3 -3
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { DepartureFilter, DepartureMode, DepartureOrder, DepartureSkip } from "../..";
|
|
2
|
+
import type { Moment } from "@golemio/core/dist/shared/moment-timezone";
|
|
3
|
+
export interface IGetDeparturesOptions {
|
|
4
|
+
aswIds?: string[];
|
|
5
|
+
cisIds?: string[];
|
|
6
|
+
gtfsIds?: string[];
|
|
7
|
+
names?: string[];
|
|
8
|
+
total: number;
|
|
9
|
+
limit: number;
|
|
10
|
+
offset: number;
|
|
11
|
+
mode: DepartureMode;
|
|
12
|
+
minutesBefore: number;
|
|
13
|
+
minutesAfter: number;
|
|
14
|
+
timeFrom?: Moment;
|
|
15
|
+
order: DepartureOrder;
|
|
16
|
+
filter: DepartureFilter;
|
|
17
|
+
skip: DepartureSkip[];
|
|
18
|
+
includeMetroTrains?: boolean;
|
|
19
|
+
airCondition?: boolean;
|
|
20
|
+
timezone: string;
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IGetDeparturesOptions.js","sourceRoot":"","sources":["../../../../../src/output-gateway/pid/models/interfaces/IGetDeparturesOptions.ts"],"names":[],"mappings":""}
|
|
@@ -84,6 +84,8 @@ let TransferFacade = exports.TransferFacade = class TransferFacade {
|
|
|
84
84
|
filter: pid_1.DepartureFilter.ROUTE_HEADING_ONCE_NOGAP_FILL,
|
|
85
85
|
skip: [pid_1.DepartureSkip.CANCELED],
|
|
86
86
|
departuresDirections: [],
|
|
87
|
+
runScheduleMap: null,
|
|
88
|
+
untrackedTrips: null, // not used in this context
|
|
87
89
|
};
|
|
88
90
|
}
|
|
89
91
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransferFacade.js","sourceRoot":"","sources":["../../../../../src/output-gateway/pid/service/facade/TransferFacade.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAAgI;AAChI,mDAA2D;AAC3D,qDAAoD;AACpD,+FAA0E;AAC1E,0HAAoG;AACpG,4CAA8C;AAC9C,6EAA8F;AAE9F,iEAAwE;AACxE,wGAAqG;AAG9F,IAAM,cAAc,4BAApB,MAAM,cAAc;IACvB,YACqD,mBAAyC,EAC9B,uBAAwD;QADnE,wBAAmB,GAAnB,mBAAmB,CAAsB;QAC9B,4BAAuB,GAAvB,uBAAuB,CAAiC;IACrH,CAAC;IAEJ;;;;;OAKG;IACI,KAAK,CAAC,qBAAqB,CAC9B,OAAiB,EACjB,UAAyB,EACzB,aAAqB,EACrB,aAAqB,EACrB,QAAQ,GAAG,yBAAgB,CAAC,QAAQ;QAEpC,IAAI,iBAAiB,GAAyB,EAAE,CAAC;QACjD,IAAI;YACA,iBAAiB,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,qBAAqB,CAAC;gBACrE,QAAQ,EAAE,OAAO;gBACjB,aAAa;gBACb,aAAa;aAChB,CAAC,CAAC;SACN;QAAC,OAAO,KAAK,EAAE;YACZ,IAAI,KAAK,YAAY,qCAAoB,EAAE;gBACvC,MAAM,KAAK,CAAC;aACf;YAED,MAAM,IAAI,6BAAY,CAAC,wCAAwC,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;SACvG;QAED,IAAI,iBAAiB,CAAC,MAAM,KAAK,CAAC,EAAE;YAChC,OAAO,EAAE,CAAC;SACb;QAED,IAAI,kBAAkB,GAAyB,EAAE,CAAC;QAClD,IAAI;YACA,MAAM,mBAAmB,GAAG,IAAI,2BAAkB,CAAC,iBAAiB,EAAE;gBAClE,GAAG,IAAI,CAAC,cAAc;gBACtB,QAAQ,EAAE,QAAQ;gBAClB,UAAU;aACb,CAAC,CAAC,yBAAyB,EAAE,CAAC;YAE/B,kBAAkB,GAAG,IAAI,CAAC,uBAAuB,CAAC,cAAc,CAAC,mBAAmB,CAAC,CAAC;SACzF;QAAC,OAAO,KAAK,EAAE;YACZ,IAAI,KAAK,YAAY,qCAAoB,EAAE;gBACvC,MAAM,KAAK,CAAC;aACf;YAED,MAAM,IAAI,6BAAY,CAAC,uCAAuC,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;SACtG;QAED,OAAO,kBAAkB,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,IAAY,cAAc;QACtB,OAAO;YACH,KAAK,EAAE,EAAE;YACT,KAAK,EAAE,EAAE;YACT,MAAM,EAAE,CAAC;YACT,IAAI,EAAE,mBAAa,CAAC,UAAU;YAC9B,KAAK,EAAE,oBAAc,CAAC,IAAI;YAC1B,MAAM,EAAE,qBAAe,CAAC,6BAA6B;YACrD,IAAI,EAAE,CAAC,mBAAa,CAAC,QAAQ,CAAC;YAC9B,oBAAoB,EAAE,EAAE;
|
|
1
|
+
{"version":3,"file":"TransferFacade.js","sourceRoot":"","sources":["../../../../../src/output-gateway/pid/service/facade/TransferFacade.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAAgI;AAChI,mDAA2D;AAC3D,qDAAoD;AACpD,+FAA0E;AAC1E,0HA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AK,CAAC;aACf;YAED,MAAM,IAAI,6BAAY,CAAC,uCAAuC,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;SACtG;QAED,OAAO,kBAAkB,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,IAAY,cAAc;QACtB,OAAO;YACH,KAAK,EAAE,EAAE;YACT,KAAK,EAAE,EAAE;YACT,MAAM,EAAE,CAAC;YACT,IAAI,EAAE,mBAAa,CAAC,UAAU;YAC9B,KAAK,EAAE,oBAAc,CAAC,IAAI;YAC1B,MAAM,EAAE,qBAAe,CAAC,6BAA6B;YACrD,IAAI,EAAE,CAAC,mBAAa,CAAC,QAAQ,CAAC;YAC9B,oBAAoB,EAAE,EAAE;YACxB,cAAc,EAAE,IAAI;YACpB,cAAc,EAAE,IAAI,EAAE,2BAA2B;SACpD,CAAC;IACN,CAAC;CACJ,CAAA;yBA3EY,cAAc;IAD1B,IAAA,qBAAU,GAAE;IAGJ,WAAA,IAAA,iBAAM,EAAC,uBAAU,CAAC,oBAAoB,CAAC,CAAA;IACvC,WAAA,IAAA,iBAAM,EAAC,uBAAU,CAAC,+BAA+B,CAAC,CAAA;qCADmB,kCAAoB;QACL,iEAA+B;GAH/G,cAAc,CA2E1B"}
|
|
@@ -8,10 +8,12 @@ export declare class PublicVehiclePositionsRepository implements IVehiclePositio
|
|
|
8
8
|
private log;
|
|
9
9
|
private setName;
|
|
10
10
|
constructor(redisConnector: IoRedisConnector, log: ILogger);
|
|
11
|
+
setCurrentSetName(name: string): void;
|
|
11
12
|
getAllVehicleIds(boundingBox: IBoundingBoxWithCenter): Promise<string[]>;
|
|
12
13
|
getAllVehiclePositions(vehicleIds: string[], tripIds?: string[]): Promise<IPublicApiCacheDto[]>;
|
|
13
14
|
getAllVehiclePositionsForMultipleTrips(tripIds: string[]): Promise<Map<string, IPublicApiCacheDto[]>>;
|
|
14
|
-
|
|
15
|
+
getTripsWithUntrackedVehicles(tripIds: string[]): Promise<Set<string>>;
|
|
15
16
|
getDetailedVehiclePosition(vehicleId: string, tripId?: string): Promise<IPublicApiCacheDto | null>;
|
|
16
|
-
|
|
17
|
+
private getVehicleIdsForMultiple;
|
|
18
|
+
private getCanceledTrips;
|
|
17
19
|
}
|
|
@@ -24,6 +24,9 @@ let PublicVehiclePositionsRepository = exports.PublicVehiclePositionsRepository
|
|
|
24
24
|
this.log = log;
|
|
25
25
|
this.setName = undefined; // loaded via pub sub
|
|
26
26
|
}
|
|
27
|
+
setCurrentSetName(name) {
|
|
28
|
+
this.setName = name;
|
|
29
|
+
}
|
|
27
30
|
async getAllVehicleIds(boundingBox) {
|
|
28
31
|
if (!this.setName) {
|
|
29
32
|
this.log.debug("Empty setName for public vehicle positions api.");
|
|
@@ -37,8 +40,8 @@ let PublicVehiclePositionsRepository = exports.PublicVehiclePositionsRepository
|
|
|
37
40
|
try {
|
|
38
41
|
vehicleIds = (await connection.geosearch(this.setName, "FROMLONLAT", boundingBox.centerPoint.longitude, boundingBox.centerPoint.latitude, "BYBOX", boundingBox.width, boundingBox.height, "m", "ASC"));
|
|
39
42
|
}
|
|
40
|
-
catch (
|
|
41
|
-
throw new golemio_errors_1.GeneralError(
|
|
43
|
+
catch (error) {
|
|
44
|
+
throw new golemio_errors_1.GeneralError("Cannot get vehicle ids from cache", this.constructor.name, error);
|
|
42
45
|
}
|
|
43
46
|
return vehicleIds;
|
|
44
47
|
}
|
|
@@ -61,8 +64,8 @@ let PublicVehiclePositionsRepository = exports.PublicVehiclePositionsRepository
|
|
|
61
64
|
}
|
|
62
65
|
vehiclePositions = await connection.mget(keys);
|
|
63
66
|
}
|
|
64
|
-
catch (
|
|
65
|
-
throw new golemio_errors_1.GeneralError(
|
|
67
|
+
catch (error) {
|
|
68
|
+
throw new golemio_errors_1.GeneralError("Cannot get vehicle positions from cache", this.constructor.name, error);
|
|
66
69
|
}
|
|
67
70
|
const parsedVehiclePositions = [];
|
|
68
71
|
for (const vehiclePosition of vehiclePositions) {
|
|
@@ -72,8 +75,8 @@ let PublicVehiclePositionsRepository = exports.PublicVehiclePositionsRepository
|
|
|
72
75
|
try {
|
|
73
76
|
parsedVehiclePositions.push(JSON.parse(vehiclePosition));
|
|
74
77
|
}
|
|
75
|
-
catch (
|
|
76
|
-
throw new golemio_errors_1.GeneralError(
|
|
78
|
+
catch (error) {
|
|
79
|
+
throw new golemio_errors_1.GeneralError("Cannot parse vehicle position", this.constructor.name, error);
|
|
77
80
|
}
|
|
78
81
|
}
|
|
79
82
|
return parsedVehiclePositions;
|
|
@@ -87,46 +90,20 @@ let PublicVehiclePositionsRepository = exports.PublicVehiclePositionsRepository
|
|
|
87
90
|
if (!this.redisConnector.isConnected()) {
|
|
88
91
|
await this.redisConnector.connect();
|
|
89
92
|
}
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
futurePipeline.lrange(`${this.setName}:future-trip-${tripId}`, 0, -1);
|
|
98
|
-
}
|
|
99
|
-
try {
|
|
100
|
-
const [trips, futureTrips] = await Promise.all([pipeline.exec(), futurePipeline.exec()]);
|
|
101
|
-
for (const [err, vehicleIds] of trips) {
|
|
102
|
-
if (err) {
|
|
103
|
-
throw new golemio_errors_1.GeneralError("Cannot get vehicle ids for trip from cache", this.constructor.name, err);
|
|
104
|
-
}
|
|
105
|
-
vehicleIdsByTrip.set(tripIds[vehicleIdsByTrip.size], vehicleIds);
|
|
106
|
-
}
|
|
107
|
-
for (const [err, vehicleIds] of futureTrips) {
|
|
108
|
-
if (err) {
|
|
109
|
-
throw new golemio_errors_1.GeneralError("Cannot get vehicle ids for future-trip from cache", this.constructor.name, err);
|
|
110
|
-
}
|
|
111
|
-
vehicleIdsByFutureTrip.set(tripIds[vehicleIdsByFutureTrip.size], vehicleIds);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
catch (err) {
|
|
115
|
-
if (err instanceof golemio_errors_1.GeneralError) {
|
|
116
|
-
throw err;
|
|
117
|
-
}
|
|
118
|
-
throw new golemio_errors_1.GeneralError("Cannot get vehicle ids for trip from cache", this.constructor.name, err);
|
|
119
|
-
}
|
|
120
|
-
const positionValues = Array.from(new Set([...vehicleIdsByTrip.values(), ...vehicleIdsByFutureTrip.values()].flat()));
|
|
121
|
-
if (positionValues.length > 0) {
|
|
122
|
-
const allPositions = await this.getAllVehiclePositions(positionValues);
|
|
93
|
+
const [vehicleIdsCurrent, vehicleIdsFuture] = await Promise.all([
|
|
94
|
+
this.getVehicleIdsForMultiple(tripIds, "trip"),
|
|
95
|
+
this.getVehicleIdsForMultiple(tripIds, "future-trip"),
|
|
96
|
+
]);
|
|
97
|
+
const vehicleIds = Array.from(new Set([...vehicleIdsCurrent, ...vehicleIdsFuture]));
|
|
98
|
+
if (vehicleIds.length > 0) {
|
|
99
|
+
const allPositions = await this.getAllVehiclePositions(vehicleIds);
|
|
123
100
|
for (const position of allPositions) {
|
|
124
101
|
if (!positionsByTrip.has(position.gtfs_trip_id)) {
|
|
125
102
|
positionsByTrip.set(position.gtfs_trip_id, []);
|
|
126
103
|
}
|
|
127
104
|
positionsByTrip.get(position.gtfs_trip_id).push(position);
|
|
128
105
|
}
|
|
129
|
-
const futurePositions = await this.getAllVehiclePositions(
|
|
106
|
+
const futurePositions = await this.getAllVehiclePositions(vehicleIds, tripIds);
|
|
130
107
|
for (const position of futurePositions) {
|
|
131
108
|
if (!positionsByTrip.has(position.gtfs_trip_id)) {
|
|
132
109
|
positionsByTrip.set(position.gtfs_trip_id, []);
|
|
@@ -140,31 +117,29 @@ let PublicVehiclePositionsRepository = exports.PublicVehiclePositionsRepository
|
|
|
140
117
|
}
|
|
141
118
|
return positionsByTrip;
|
|
142
119
|
}
|
|
143
|
-
async
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
return
|
|
120
|
+
async getTripsWithUntrackedVehicles(tripIds) {
|
|
121
|
+
const untrackedTrips = new Set();
|
|
122
|
+
if (!this.setName || tripIds.length === 0) {
|
|
123
|
+
this.log.debug("Empty setName for public vehicle positions api or empty trip ids.");
|
|
124
|
+
return untrackedTrips;
|
|
148
125
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
keys.push(`${this.setName}:canceled-trips-${tripId}`);
|
|
126
|
+
if (!this.redisConnector.isConnected()) {
|
|
127
|
+
await this.redisConnector.connect();
|
|
152
128
|
}
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
parsedCanceledTrips.push(JSON.parse(canceledTrip));
|
|
161
|
-
}
|
|
162
|
-
catch (err) {
|
|
163
|
-
throw new golemio_errors_1.GeneralError(`${this.constructor.name}: Cannot parse canceled trip: ${err.message}`, this.constructor.name, err);
|
|
129
|
+
const vehicleIds = await this.getVehicleIdsForMultiple(tripIds, "trip");
|
|
130
|
+
try {
|
|
131
|
+
// TODO optimization point here - use JSON.GET once it's available in the redis/valkey server
|
|
132
|
+
const allPositions = await this.getAllVehiclePositions(vehicleIds);
|
|
133
|
+
for (let i = 0; i < allPositions.length; i++) {
|
|
134
|
+
if (allPositions[i].delay === null) {
|
|
135
|
+
untrackedTrips.add(allPositions[i].gtfs_trip_id);
|
|
164
136
|
}
|
|
165
137
|
}
|
|
166
138
|
}
|
|
167
|
-
|
|
139
|
+
catch (error) {
|
|
140
|
+
throw new golemio_errors_1.GeneralError("Cannot get vehicle positions from cache", this.constructor.name, error);
|
|
141
|
+
}
|
|
142
|
+
return untrackedTrips;
|
|
168
143
|
}
|
|
169
144
|
// Current trips are saved in the cache with key made from vehicleId only. For future trips tripId has to be also provided.
|
|
170
145
|
async getDetailedVehiclePosition(vehicleId, tripId) {
|
|
@@ -181,9 +156,9 @@ let PublicVehiclePositionsRepository = exports.PublicVehiclePositionsRepository
|
|
|
181
156
|
const key = tripId ? `${this.setName}:future-trip-${vehicleId}-${tripId}` : `${this.setName}:vehicle-${vehicleId}`;
|
|
182
157
|
vehiclePosition = await connection.get(key);
|
|
183
158
|
}
|
|
184
|
-
catch (
|
|
185
|
-
this.log.error(
|
|
186
|
-
throw new golemio_errors_1.GeneralError(
|
|
159
|
+
catch (error) {
|
|
160
|
+
this.log.error(error, "Cannot get vehicle position from cache");
|
|
161
|
+
throw new golemio_errors_1.GeneralError("Cannot get vehicle position from cache", this.constructor.name, error);
|
|
187
162
|
}
|
|
188
163
|
if (vehiclePosition === null) {
|
|
189
164
|
this.log.info(`${this.constructor.name}: Cannot find vehicle_id ${vehicleId}`);
|
|
@@ -192,13 +167,60 @@ let PublicVehiclePositionsRepository = exports.PublicVehiclePositionsRepository
|
|
|
192
167
|
try {
|
|
193
168
|
return JSON.parse(vehiclePosition);
|
|
194
169
|
}
|
|
195
|
-
catch (
|
|
196
|
-
this.log.error(
|
|
197
|
-
throw new golemio_errors_1.GeneralError(
|
|
170
|
+
catch (error) {
|
|
171
|
+
this.log.error(error, `Cannot parse ${vehicleId}`);
|
|
172
|
+
throw new golemio_errors_1.GeneralError(`Cannot parse ${vehicleId}`, this.constructor.name, error);
|
|
198
173
|
}
|
|
199
174
|
}
|
|
200
|
-
|
|
201
|
-
|
|
175
|
+
async getVehicleIdsForMultiple(tripIds, keyPrefix) {
|
|
176
|
+
const vehicleIdsByTrip = new Map();
|
|
177
|
+
const connection = this.redisConnector.getConnection();
|
|
178
|
+
const pipeline = connection.pipeline();
|
|
179
|
+
for (const tripId of tripIds) {
|
|
180
|
+
pipeline.lrange(`${this.setName}:${keyPrefix}-${tripId}`, 0, -1);
|
|
181
|
+
}
|
|
182
|
+
try {
|
|
183
|
+
const trips = await pipeline.exec();
|
|
184
|
+
for (const [error, vehicleIds] of trips) {
|
|
185
|
+
if (error) {
|
|
186
|
+
throw new golemio_errors_1.GeneralError(`Cannot get vehicle ids for ${keyPrefix} from cache`, this.constructor.name, error);
|
|
187
|
+
}
|
|
188
|
+
vehicleIdsByTrip.set(tripIds[vehicleIdsByTrip.size], vehicleIds);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
if (error instanceof golemio_errors_1.GeneralError) {
|
|
193
|
+
throw error;
|
|
194
|
+
}
|
|
195
|
+
throw new golemio_errors_1.GeneralError(`Cannot get vehicle ids for ${keyPrefix} from cache`, this.constructor.name, error);
|
|
196
|
+
}
|
|
197
|
+
return Array.from(vehicleIdsByTrip.values()).flat();
|
|
198
|
+
}
|
|
199
|
+
async getCanceledTrips(tripIds) {
|
|
200
|
+
const connection = this.redisConnector.getConnection();
|
|
201
|
+
const parsedCanceledTrips = [];
|
|
202
|
+
if (tripIds.length === 0) {
|
|
203
|
+
return [];
|
|
204
|
+
}
|
|
205
|
+
const keys = [];
|
|
206
|
+
for (const tripId of tripIds) {
|
|
207
|
+
keys.push(`${this.setName}:canceled-trips-${tripId}`);
|
|
208
|
+
}
|
|
209
|
+
const canceledTrips = await connection.mget(keys);
|
|
210
|
+
for (const canceledTrip of canceledTrips) {
|
|
211
|
+
if (canceledTrip === null) {
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
try {
|
|
216
|
+
parsedCanceledTrips.push(JSON.parse(canceledTrip));
|
|
217
|
+
}
|
|
218
|
+
catch (error) {
|
|
219
|
+
throw new golemio_errors_1.GeneralError("Cannot parse canceled trip", this.constructor.name, error);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return parsedCanceledTrips;
|
|
202
224
|
}
|
|
203
225
|
};
|
|
204
226
|
exports.PublicVehiclePositionsRepository = PublicVehiclePositionsRepository = __decorate([
|
package/dist/output-gateway/public/data-access/redis/PublicVehiclePositionsRepository.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PublicVehiclePositionsRepository.js","sourceRoot":"","sources":["../../../../../src/output-gateway/public/data-access/redis/PublicVehiclePositionsRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAGA,oGAAiG;AACjG,wEAAqE;AAErE,+DAAuE;AACvE,6EAAwE;AACxE,iEAAwE;AAGjE,IAAM,gCAAgC,8CAAtC,MAAM,gCAAgC;IAGzC,YAC2C,cAAwC,EACrD,GAAoB;QADC,mBAAc,GAAd,cAAc,CAAkB;QAC7C,QAAG,GAAH,GAAG,CAAS;QAJ1C,YAAO,GAAuB,SAAS,CAAC,CAAC,qBAAqB;IAKnE,CAAC;IAEG,KAAK,CAAC,gBAAgB,CAAC,WAAmC;QAC7D,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACf,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,iDAAiD,CAAC,CAAC;YAClE,OAAO,EAAE,CAAC;SACb;QAED,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,WAAW,EAAE,EAAE;YACpC,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;SACvC;QAED,MAAM,UAAU,GAAG,IAAI,CAAC,cAAc,CAAC,aAAa,EAAE,CAAC;QACvD,IAAI,UAAU,GAAa,EAAE,CAAC;QAE9B,IAAI;YACA,UAAU,GAAG,CAAC,MAAM,UAAU,CAAC,SAAS,CACpC,IAAI,CAAC,OAAO,EACZ,YAAY,EACZ,WAAW,CAAC,WAAW,CAAC,SAAS,EACjC,WAAW,CAAC,WAAW,CAAC,QAAQ,EAChC,OAAO,EACP,WAAW,CAAC,KAAK,EACjB,WAAW,CAAC,MAAM,EAClB,GAAG,EACH,KAAK,CACR,CAAa,CAAC;SAClB;QAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"PublicVehiclePositionsRepository.js","sourceRoot":"","sources":["../../../../../src/output-gateway/public/data-access/redis/PublicVehiclePositionsRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAGA,oGAAiG;AACjG,wEAAqE;AAErE,+DAAuE;AACvE,6EAAwE;AACxE,iEAAwE;AAGjE,IAAM,gCAAgC,8CAAtC,MAAM,gCAAgC;IAGzC,YAC2C,cAAwC,EACr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c,CAAC,cAAc,CAAC,CAAA;IACrC,WAAA,IAAA,iBAAM,EAAC,qBAAS,CAAC,MAAM,CAAC,CAAA;qCADsC,mCAAgB;GAJ1E,gCAAgC,CAyP5C"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { IPublicApiCacheDto } from "../../../../schema-definitions/vehicle-positions/redis/interfaces/IPublicApiCacheDto";
|
|
2
2
|
import { IBoundingBoxWithCenter } from "../IBoudingBox";
|
|
3
3
|
export interface IVehiclePositionsRepository {
|
|
4
|
+
setCurrentSetName(name: string): void;
|
|
4
5
|
getAllVehicleIds(boundingBox: IBoundingBoxWithCenter): Promise<string[]>;
|
|
5
6
|
getAllVehiclePositions(vehicleIds: string[]): Promise<IPublicApiCacheDto[]>;
|
|
6
7
|
getAllVehiclePositionsForMultipleTrips(tripIds: string[]): Promise<Map<string, IPublicApiCacheDto[]>>;
|
|
7
8
|
getDetailedVehiclePosition(vehicleId: string, tripdId?: string): Promise<IPublicApiCacheDto | null>;
|
|
8
|
-
|
|
9
|
+
getTripsWithUntrackedVehicles(tripIds: string[]): Promise<Set<string>>;
|
|
9
10
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IRunTripsRedisRepository } from "../../domain/repository/IRunTripsRedisRepository";
|
|
2
|
+
import { IGtfsRunTripCacheDto } from "../../../../schema-definitions/vehicle-positions/redis/interfaces/IGtfsRunTripCacheDto";
|
|
3
|
+
import { IoRedisConnector } from "@golemio/core/dist/helpers/data-access/redis/IoRedisConnector";
|
|
4
|
+
import { ILogger } from "@golemio/core/dist/helpers/logger/LoggerProvider";
|
|
5
|
+
export declare class RunTripsRedisRepository implements IRunTripsRedisRepository {
|
|
6
|
+
private redisConnector;
|
|
7
|
+
private log;
|
|
8
|
+
constructor(redisConnector: IoRedisConnector, log: ILogger);
|
|
9
|
+
getMultipleSchedule(runTuples: string[]): Promise<Array<IGtfsRunTripCacheDto | null>>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.RunTripsRedisRepository = void 0;
|
|
16
|
+
const const_1 = require("../../../../schema-definitions/ropid-gtfs/redis/const");
|
|
17
|
+
const IoRedisConnector_1 = require("@golemio/core/dist/helpers/data-access/redis/IoRedisConnector");
|
|
18
|
+
const CoreToken_1 = require("@golemio/core/dist/helpers/ioc/CoreToken");
|
|
19
|
+
const ioc_1 = require("@golemio/core/dist/output-gateway/ioc");
|
|
20
|
+
const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
|
|
21
|
+
const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
|
|
22
|
+
let RunTripsRedisRepository = exports.RunTripsRedisRepository = class RunTripsRedisRepository {
|
|
23
|
+
constructor(redisConnector, log) {
|
|
24
|
+
this.redisConnector = redisConnector;
|
|
25
|
+
this.log = log;
|
|
26
|
+
}
|
|
27
|
+
async getMultipleSchedule(runTuples) {
|
|
28
|
+
if (!runTuples.length) {
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
if (!this.redisConnector.isConnected()) {
|
|
32
|
+
await this.redisConnector.connect();
|
|
33
|
+
}
|
|
34
|
+
const connection = this.redisConnector.getConnection();
|
|
35
|
+
let runTripCache = [];
|
|
36
|
+
try {
|
|
37
|
+
runTripCache = await connection.mget(runTuples.map((runTuple) => `${const_1.GTFS_RUN_SCHEDULE_NAMESPACE_PREFIX}:${runTuple}`));
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
throw new golemio_errors_1.GeneralError("Cannot get run trips from cache", this.constructor.name, error);
|
|
41
|
+
}
|
|
42
|
+
let gtfsRunTripDtos = [];
|
|
43
|
+
for (const cache of runTripCache) {
|
|
44
|
+
if (cache === null) {
|
|
45
|
+
this.log.info(`${this.constructor.name}: Cannot find run trip cache`);
|
|
46
|
+
gtfsRunTripDtos.push(null);
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
gtfsRunTripDtos.push(JSON.parse(cache));
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
throw new golemio_errors_1.GeneralError("Cannot parse run trip cache", this.constructor.name, error);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return gtfsRunTripDtos;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
exports.RunTripsRedisRepository = RunTripsRedisRepository = __decorate([
|
|
60
|
+
(0, tsyringe_1.injectable)(),
|
|
61
|
+
__param(0, (0, tsyringe_1.inject)(ioc_1.ContainerToken.RedisConnector)),
|
|
62
|
+
__param(1, (0, tsyringe_1.inject)(CoreToken_1.CoreToken.Logger)),
|
|
63
|
+
__metadata("design:paramtypes", [IoRedisConnector_1.IoRedisConnector, Object])
|
|
64
|
+
], RunTripsRedisRepository);
|
|
65
|
+
//# sourceMappingURL=RunTripsRedisRepository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RunTripsRedisRepository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CAAC,CAAC;gBAC3B,SAAS;aACZ;YAED,IAAI;gBACA,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;aAC3C;YAAC,OAAO,KAAK,EAAE;gBACZ,MAAM,IAAI,6BAAY,CAAC,6BAA6B,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;aACvF;SACJ;QAED,OAAO,eAAe,CAAC;IAC3B,CAAC;CACJ,CAAA;kCA3CY,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,CA2CnC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IRunTripsRedisRepository.js","sourceRoot":"","sources":["../../../../../src/output-gateway/ropid-gtfs/domain/repository/IRunTripsRedisRepository.ts"],"names":[],"mappings":""}
|
|
@@ -18,7 +18,7 @@ exports.ValidationArrays = {
|
|
|
18
18
|
"routeHeadingOnceNoGap",
|
|
19
19
|
"routeHeadingOnceNoGapFill",
|
|
20
20
|
],
|
|
21
|
-
skip: ["untracked", "canceled", "atStop" /*, "onInfotext"*/],
|
|
21
|
+
skip: ["untracked", "missing", "canceled", "atStop" /*, "onInfotext"*/],
|
|
22
22
|
},
|
|
23
23
|
// TODO replace moment.tz.names() with Intl.supportedValuesOf("timeZone") after migrating to Node 18
|
|
24
24
|
preferredTimezone: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validations.js","sourceRoot":"","sources":["../../../../src/output-gateway/shared/constants/validations.ts"],"names":[],"mappings":";;;;;;AAAA,gGAA+D;AAElD,QAAA,gBAAgB,GAAG;IAC5B,eAAe,EAAE;QACb,aAAa,EAAE,CAAC,YAAY,EAAE,UAAU,EAAE,OAAO,CAAC;QAClD,KAAK,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC;QAC5B,MAAM,EAAE;YACJ,MAAM;YACN,WAAW;YACX,kBAAkB;YAClB,eAAe;YACf,sBAAsB;YACtB,uBAAuB;YACvB,2BAA2B;SAC9B;QACD,IAAI,EAAE,CAAC,WAAW,EAAE,UAAU,EAAE,QAAQ,CAAC,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"validations.js","sourceRoot":"","sources":["../../../../src/output-gateway/shared/constants/validations.ts"],"names":[],"mappings":";;;;;;AAAA,gGAA+D;AAElD,QAAA,gBAAgB,GAAG;IAC5B,eAAe,EAAE;QACb,aAAa,EAAE,CAAC,YAAY,EAAE,UAAU,EAAE,OAAO,CAAC;QAClD,KAAK,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC;QAC5B,MAAM,EAAE;YACJ,MAAM;YACN,WAAW;YACX,kBAAkB;YAClB,eAAe;YACf,sBAAsB;YACtB,uBAAuB;YACvB,2BAA2B;SAC9B;QACD,IAAI,EAAE,CAAC,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,CAAC,kBAAkB,CAAC;KAC1E;IACD,oGAAoG;IACpG,iBAAiB,EAAE;QACf,GAAG,yBAAM,CAAC,EAAE,CAAC,KAAK,EAAE;QACpB,GAAG,yBAAM,CAAC,EAAE;aACP,KAAK,EAAE;YACR,iDAAiD;aAChD,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACpC,0BAA0B;aACzB,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;KAC/C;CACJ,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PUBLIC_DEPARTURE_NAMESPACE_PREFIX = void 0;
|
|
3
|
+
exports.PUBLIC_DEPARTURE_NAMESPACE_PREFIX = exports.GTFS_RUN_SCHEDULE_NAMESPACE_PREFIX = void 0;
|
|
4
|
+
exports.GTFS_RUN_SCHEDULE_NAMESPACE_PREFIX = "gtfsRunSchedule";
|
|
4
5
|
exports.PUBLIC_DEPARTURE_NAMESPACE_PREFIX = "gtfsPublicDepartureCache";
|
|
5
6
|
//# sourceMappingURL=const.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"const.js","sourceRoot":"","sources":["../../../../src/schema-definitions/ropid-gtfs/redis/const.ts"],"names":[],"mappings":";;;AAAa,QAAA,iCAAiC,GAAG,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"const.js","sourceRoot":"","sources":["../../../../src/schema-definitions/ropid-gtfs/redis/const.ts"],"names":[],"mappings":";;;AAAa,QAAA,kCAAkC,GAAG,iBAAiB,CAAC;AACvD,QAAA,iCAAiC,GAAG,0BAA0B,CAAC"}
|
package/docs/openapi-output.yaml
CHANGED
|
@@ -976,12 +976,20 @@ paths:
|
|
|
976
976
|
example: "routeOnce"
|
|
977
977
|
- name: skip
|
|
978
978
|
in: query
|
|
979
|
-
description:
|
|
980
|
-
|
|
979
|
+
description: |
|
|
980
|
+
Filters out trips matching the given states.
|
|
981
|
+
Multiple filters can be applied using array syntax, e.g., `&skip[]=canceled&skip[]=atStop`.
|
|
982
|
+
Using both `untracked` and `missing` will exclude all untracked vehicles, as missing vehicles are a subset of untracked vehicles.
|
|
983
|
+
We recommend using `missing` instead of `untracked`, as skipping all untracked vehicles may result in departures not appearing in the API response until the last few minutes before departure, especially for departure boards near the starting station/stop.
|
|
981
984
|
required: false
|
|
982
985
|
schema:
|
|
983
986
|
type: string
|
|
984
987
|
example: "canceled"
|
|
988
|
+
enum:
|
|
989
|
+
- canceled
|
|
990
|
+
- atStop
|
|
991
|
+
- untracked
|
|
992
|
+
- missing
|
|
985
993
|
- name: limit
|
|
986
994
|
in: query
|
|
987
995
|
description: Limits the number of items in response. The maximum is 1000 (default value is 20).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@golemio/pid",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.3-dev.1636796644",
|
|
4
4
|
"description": "Golemio PID Module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"@golemio/core": ">=1.16.0-rc.1551191551"
|
|
77
77
|
},
|
|
78
78
|
"dependencies": {
|
|
79
|
-
"@golemio/ovapi-gtfs-realtime-bindings": "1.2.
|
|
79
|
+
"@golemio/ovapi-gtfs-realtime-bindings": "1.2.4-dev.1288219308",
|
|
80
80
|
"@turf/turf": "^6.5.0",
|
|
81
81
|
"cheap-ruler": "^3.0.2",
|
|
82
82
|
"csv-parser": "^3.0.0",
|
|
@@ -84,4 +84,4 @@
|
|
|
84
84
|
"html-entities": "^2.3.3",
|
|
85
85
|
"pg-copy-streams": "^5.1.1"
|
|
86
86
|
}
|
|
87
|
-
}
|
|
87
|
+
}
|