@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
|
@@ -1,34 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { IDepartureBoardOutputDto } from "../domain/DepartureInterfaces";
|
|
2
|
+
import { IGetDeparturesOptions } from "./interfaces/IGetDeparturesOptions";
|
|
3
3
|
declare class PIDDepartureBoardsModel {
|
|
4
|
-
private
|
|
5
|
-
private ropidDeparturesDirectionsModel;
|
|
6
|
-
private departuresRepository;
|
|
4
|
+
private readonly log;
|
|
5
|
+
private readonly ropidDeparturesDirectionsModel;
|
|
6
|
+
private readonly departuresRepository;
|
|
7
|
+
private readonly runTripsRedisRepository;
|
|
8
|
+
private readonly positionsRedisRepository;
|
|
7
9
|
private readonly infotextRepository;
|
|
8
10
|
private readonly infotextTransformation;
|
|
9
11
|
constructor();
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
gtfsIds?: string[];
|
|
18
|
-
names?: string[];
|
|
19
|
-
total: number;
|
|
20
|
-
limit: number;
|
|
21
|
-
offset: number;
|
|
22
|
-
mode: DepartureMode;
|
|
23
|
-
minutesBefore: number;
|
|
24
|
-
minutesAfter: number;
|
|
25
|
-
timeFrom?: Moment;
|
|
26
|
-
order: DepartureOrder;
|
|
27
|
-
filter: DepartureFilter;
|
|
28
|
-
skip: DepartureSkip[];
|
|
29
|
-
includeMetroTrains?: boolean;
|
|
30
|
-
airCondition?: boolean;
|
|
31
|
-
timezone: string;
|
|
32
|
-
}) => Promise<any>;
|
|
12
|
+
getAll(options: IGetDeparturesOptions): Promise<IDepartureBoardOutputDto>;
|
|
13
|
+
private retrieveAndReturnStops;
|
|
14
|
+
private retrieveAndReturnInfotexts;
|
|
15
|
+
private retrieveAndReturnDirections;
|
|
16
|
+
private retrieveAndReturnDepartures;
|
|
17
|
+
private retrieveAndReturnRunTrips;
|
|
18
|
+
private retrieveAndReturnUntrackedTrips;
|
|
33
19
|
}
|
|
34
20
|
export { PIDDepartureBoardsModel };
|
|
@@ -12,103 +12,223 @@ const trace_provider_1 = require("@golemio/core/dist/monitoring/opentelemetry/tr
|
|
|
12
12
|
const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
|
|
13
13
|
const moment_timezone_1 = __importDefault(require("@golemio/core/dist/shared/moment-timezone"));
|
|
14
14
|
const _1 = require(".");
|
|
15
|
+
const __1 = require("..");
|
|
15
16
|
const Di_1 = require("../ioc/Di");
|
|
16
17
|
const OgPidToken_1 = require("../ioc/OgPidToken");
|
|
17
18
|
const PIDDepartureModel_1 = __importDefault(require("./helpers/PIDDepartureModel"));
|
|
19
|
+
const STOPS_MAX_COUNT = 100;
|
|
20
|
+
// TODO refactor - split into facade and multiple service/strategy classes
|
|
21
|
+
// Check V3TransferBoardsController and TransferFacade for inspiration
|
|
18
22
|
class PIDDepartureBoardsModel {
|
|
19
23
|
constructor() {
|
|
20
|
-
this.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
this.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
this.log = Di_1.OgPidContainer.resolve(CoreToken_1.CoreToken.Logger);
|
|
25
|
+
this.ropidDeparturesDirectionsModel = new _1.RopidDeparturesDirectionsModel();
|
|
26
|
+
this.departuresRepository = new data_access_1.DeparturesRepository(Di_1.OgPidContainer.resolve(CoreToken_1.CoreToken.PostgresConnector), Di_1.OgPidContainer.resolve(CoreToken_1.CoreToken.SimpleConfig));
|
|
27
|
+
this.runTripsRedisRepository = Di_1.OgPidContainer.resolve(OgPidToken_1.OgPidToken.RunTripsRedisRepository);
|
|
28
|
+
this.positionsRedisRepository = Di_1.OgPidContainer.resolve(OgPidToken_1.OgPidToken.PublicVehiclePositionsRepository);
|
|
29
|
+
this.infotextRepository = Di_1.OgPidContainer.resolve(OgPidToken_1.OgPidToken.JISInfotextRepository);
|
|
30
|
+
this.infotextTransformation = Di_1.OgPidContainer.resolve(OgPidToken_1.OgPidToken.JISInfotextDepartureTransformation);
|
|
31
|
+
}
|
|
32
|
+
async getAll(options) {
|
|
33
|
+
const currentMoment = (0, moment_timezone_1.default)();
|
|
34
|
+
//#region Data retrieval from DB (GTFS stops, infotexts, directions, departures)
|
|
35
|
+
const { stopsToInclude, stopIds } = await this.retrieveAndReturnStops(options);
|
|
36
|
+
const [infotextsToInclude, directions, departures] = await Promise.all([
|
|
37
|
+
this.retrieveAndReturnInfotexts(stopIds, currentMoment, options),
|
|
38
|
+
this.retrieveAndReturnDirections(stopIds),
|
|
39
|
+
this.retrieveAndReturnDepartures(stopIds, currentMoment, options),
|
|
40
|
+
]);
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region Data retrieval from Redis (run schedule, untracked trips)
|
|
43
|
+
let runScheduleMap = new Map();
|
|
44
|
+
let untrackedTrips = new Set();
|
|
45
|
+
const isMissingRequested = options.skip.includes(__1.DepartureSkip.MISSING) && !options.skip.includes(__1.DepartureSkip.UNTRACKED);
|
|
46
|
+
// Note: The run schedule and untracked trips are populated only if the skip[]=missing (without untracked) is present
|
|
47
|
+
// Check the PIDDeparturesModel.skip function. In other cases they are not needed
|
|
48
|
+
if (isMissingRequested) {
|
|
49
|
+
const runTuples = new Set();
|
|
50
|
+
for (const departure of departures) {
|
|
51
|
+
runTuples.add(`${departure.origin_route_name}_${departure.run_number}`);
|
|
52
|
+
}
|
|
53
|
+
const { runSchedule, runTripIds } = await this.retrieveAndReturnRunTrips(runTuples);
|
|
54
|
+
runScheduleMap = runSchedule;
|
|
55
|
+
untrackedTrips = await this.retrieveAndReturnUntrackedTrips(runTripIds);
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region Processing and returning departures
|
|
59
|
+
const spanProcessing = (0, trace_provider_1.createChildSpan)("V2PIDRouter.Processing");
|
|
60
|
+
try {
|
|
61
|
+
const departuresToInclude = new PIDDepartureModel_1.default(departures, {
|
|
62
|
+
limit: options.limit,
|
|
63
|
+
offset: options.offset,
|
|
64
|
+
total: options.total,
|
|
65
|
+
mode: options.mode,
|
|
66
|
+
order: options.order,
|
|
67
|
+
filter: options.filter,
|
|
68
|
+
skip: options.skip,
|
|
69
|
+
departuresDirections: directions,
|
|
70
|
+
timezone: options.timezone,
|
|
71
|
+
tripNumber: null,
|
|
72
|
+
runScheduleMap,
|
|
73
|
+
untrackedTrips,
|
|
74
|
+
}).toArray();
|
|
75
|
+
spanProcessing?.end();
|
|
76
|
+
return {
|
|
77
|
+
departures: departuresToInclude,
|
|
78
|
+
infotexts: infotextsToInclude,
|
|
79
|
+
stops: stopsToInclude,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
spanProcessing?.recordException(error);
|
|
84
|
+
if (error instanceof golemio_errors_1.AbstractGolemioError) {
|
|
85
|
+
throw error;
|
|
86
|
+
}
|
|
87
|
+
throw new golemio_errors_1.GeneralError("Error while processing departures", this.constructor.name, error, 500);
|
|
88
|
+
}
|
|
89
|
+
//#endregion
|
|
90
|
+
}
|
|
91
|
+
async retrieveAndReturnStops(options) {
|
|
92
|
+
const spanStops = (0, trace_provider_1.createChildSpan)("V2PIDRouter.DB.stops");
|
|
93
|
+
spanStops?.setAttributes({ ...options, timeFrom: options.timeFrom?.toString() });
|
|
94
|
+
try {
|
|
30
95
|
const stopsToInclude = await models_1.models.GTFSStopModel.GetAll({
|
|
31
96
|
includeMetroTrains: options.includeMetroTrains,
|
|
32
97
|
appendAswId: true,
|
|
33
98
|
aswIds: options.aswIds,
|
|
34
99
|
cisIds: options.cisIds,
|
|
35
100
|
gtfsIds: options.gtfsIds,
|
|
36
|
-
limit:
|
|
101
|
+
limit: STOPS_MAX_COUNT + 1,
|
|
37
102
|
locationType: StopEnums_1.GtfsStopLocationType.StopOrPlatform,
|
|
38
103
|
names: options.names,
|
|
39
104
|
returnRaw: true,
|
|
40
105
|
});
|
|
41
106
|
if (stopsToInclude.length === 0) {
|
|
42
|
-
throw new golemio_errors_1.GeneralError("No stops found.",
|
|
107
|
+
throw new golemio_errors_1.GeneralError("No stops found.", this.constructor.name, undefined, 404);
|
|
43
108
|
}
|
|
44
|
-
if (stopsToInclude.length >
|
|
45
|
-
throw new golemio_errors_1.GeneralError(`Too many stops, try lower number or split requests. The maximum is ${
|
|
109
|
+
else if (stopsToInclude.length > STOPS_MAX_COUNT) {
|
|
110
|
+
throw new golemio_errors_1.GeneralError(`Too many stops, try lower number or split requests. The maximum is ${STOPS_MAX_COUNT} stops.`, this.constructor.name, undefined, 413);
|
|
46
111
|
}
|
|
47
|
-
const
|
|
112
|
+
const stopIds = stopsToInclude.map(({ stop_id }) => stop_id);
|
|
48
113
|
spanStops?.end();
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
timeZone: options.timezone,
|
|
56
|
-
})));
|
|
57
|
-
}
|
|
58
|
-
catch (err) {
|
|
59
|
-
if (err instanceof golemio_errors_1.AbstractGolemioError) {
|
|
60
|
-
throw err;
|
|
61
|
-
}
|
|
62
|
-
throw new golemio_errors_1.GeneralError("Database error", "DepartureBoardsModel", err, 500);
|
|
114
|
+
return { stopsToInclude, stopIds };
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
spanStops?.recordException(error);
|
|
118
|
+
if (error instanceof golemio_errors_1.AbstractGolemioError) {
|
|
119
|
+
throw error;
|
|
63
120
|
}
|
|
121
|
+
throw new golemio_errors_1.GeneralError("Error while getting stops", this.constructor.name, error, 500);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
async retrieveAndReturnInfotexts(stopIds, currentMoment, options) {
|
|
125
|
+
const spanInfotexts = (0, trace_provider_1.createChildSpan)("V2PIDRouter.DB.infotexts");
|
|
126
|
+
try {
|
|
127
|
+
const infotexts = await this.infotextRepository.findAllForDepartureBoard(stopIds, (options.timeFrom ?? currentMoment).toDate());
|
|
128
|
+
const infotextsToInclude = this.infotextTransformation.transformArray(infotexts.map((infotext) => ({
|
|
129
|
+
data: infotext,
|
|
130
|
+
timeZone: options.timezone,
|
|
131
|
+
})));
|
|
64
132
|
spanInfotexts?.end();
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
throw new golemio_errors_1.GeneralError("Database error", "DepartureBoardsModel", err, 500);
|
|
133
|
+
return infotextsToInclude;
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
spanInfotexts?.recordException(error);
|
|
137
|
+
if (error instanceof golemio_errors_1.AbstractGolemioError) {
|
|
138
|
+
throw error;
|
|
72
139
|
}
|
|
140
|
+
throw new golemio_errors_1.GeneralError("Error while getting infotexts", this.constructor.name, error, 500);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
async retrieveAndReturnDirections(stopIds) {
|
|
144
|
+
const spanDirections = (0, trace_provider_1.createChildSpan)("V2PIDRouter.DB.directions");
|
|
145
|
+
try {
|
|
146
|
+
const departuresDirections = await this.ropidDeparturesDirectionsModel.GetAll(stopIds);
|
|
73
147
|
spanDirections?.end();
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
stopsIds,
|
|
81
|
-
mode: options.mode,
|
|
82
|
-
isAirCondition: !!options.airCondition,
|
|
83
|
-
});
|
|
84
|
-
const spanDepartures = (0, trace_provider_1.createChildSpan)("V2PIDRouter.DB.departures");
|
|
85
|
-
const res = {
|
|
86
|
-
departures: new PIDDepartureModel_1.default(results, {
|
|
87
|
-
limit: options.limit,
|
|
88
|
-
offset: options.offset,
|
|
89
|
-
total: options.total,
|
|
90
|
-
mode: options.mode,
|
|
91
|
-
order: options.order,
|
|
92
|
-
filter: options.filter,
|
|
93
|
-
skip: options.skip,
|
|
94
|
-
departuresDirections,
|
|
95
|
-
timezone: options.timezone,
|
|
96
|
-
tripNumber: null, // not used in this context
|
|
97
|
-
}).toArray(),
|
|
98
|
-
infotexts: infotextsToInclude,
|
|
99
|
-
stops: stopsToInclude,
|
|
100
|
-
};
|
|
101
|
-
spanDepartures?.end();
|
|
102
|
-
return res;
|
|
148
|
+
return departuresDirections;
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
spanDirections?.recordException(error);
|
|
152
|
+
if (error instanceof golemio_errors_1.AbstractGolemioError) {
|
|
153
|
+
throw error;
|
|
103
154
|
}
|
|
104
|
-
|
|
105
|
-
|
|
155
|
+
throw new golemio_errors_1.GeneralError("Error while getting directions", this.constructor.name, error, 500);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
async retrieveAndReturnDepartures(stopIds, currentMoment, options) {
|
|
159
|
+
const spanDepartures = (0, trace_provider_1.createChildSpan)("V2PIDRouter.DB.departures");
|
|
160
|
+
spanDepartures?.setAttributes({ stopIds });
|
|
161
|
+
try {
|
|
162
|
+
const minutesOffset = options.timeFrom ? options.timeFrom.diff(currentMoment, "minutes") : 0;
|
|
163
|
+
const departures = await this.departuresRepository.GetAll({
|
|
164
|
+
currentMoment,
|
|
165
|
+
minutesAfter: options.minutesAfter,
|
|
166
|
+
minutesBefore: options.minutesBefore,
|
|
167
|
+
minutesOffset,
|
|
168
|
+
stopsIds: stopIds,
|
|
169
|
+
mode: options.mode,
|
|
170
|
+
isAirCondition: !!options.airCondition,
|
|
171
|
+
});
|
|
172
|
+
spanDepartures?.end();
|
|
173
|
+
return departures;
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
spanDepartures?.recordException(error);
|
|
177
|
+
if (error instanceof golemio_errors_1.AbstractGolemioError) {
|
|
178
|
+
throw error;
|
|
106
179
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
180
|
+
throw new golemio_errors_1.GeneralError("Error while getting departures", this.constructor.name, error, 500);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
async retrieveAndReturnRunTrips(runTuples) {
|
|
184
|
+
const runScheduleMap = new Map();
|
|
185
|
+
const tripIds = new Set();
|
|
186
|
+
const spanRunTrips = (0, trace_provider_1.createChildSpan)("V2PIDRouter.Redis.runTrips");
|
|
187
|
+
try {
|
|
188
|
+
const runTuplesArray = Array.from(runTuples);
|
|
189
|
+
const runSchedule = await this.runTripsRedisRepository.getMultipleSchedule(runTuplesArray);
|
|
190
|
+
for (let i = 0; i < runSchedule.length; i++) {
|
|
191
|
+
const runTrip = runSchedule[i];
|
|
192
|
+
if (runTrip) {
|
|
193
|
+
const tuple = runTuplesArray[i];
|
|
194
|
+
runScheduleMap.set(tuple, runTrip.schedule);
|
|
195
|
+
for (const trip of runTrip.schedule) {
|
|
196
|
+
tripIds.add(trip.trip_id);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
spanRunTrips?.end();
|
|
201
|
+
}
|
|
202
|
+
catch (error) {
|
|
203
|
+
spanRunTrips?.recordException(error);
|
|
204
|
+
this.log.error(error,
|
|
205
|
+
// eslint-disable-next-line max-len
|
|
206
|
+
"Cannot retrieve run schedule. The API consumer will receive departures with missing vehicles even if they requested to skip them.");
|
|
207
|
+
}
|
|
208
|
+
finally {
|
|
209
|
+
return {
|
|
210
|
+
runSchedule: runScheduleMap,
|
|
211
|
+
runTripIds: tripIds,
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
async retrieveAndReturnUntrackedTrips(tripIds) {
|
|
216
|
+
let untrackedTrips = new Set();
|
|
217
|
+
const spanUntrackedTrips = (0, trace_provider_1.createChildSpan)("V2PIDRouter.Redis.untrackedTrips");
|
|
218
|
+
try {
|
|
219
|
+
const tripIdsArray = Array.from(tripIds);
|
|
220
|
+
untrackedTrips = await this.positionsRedisRepository.getTripsWithUntrackedVehicles(tripIdsArray);
|
|
221
|
+
spanUntrackedTrips?.end();
|
|
222
|
+
}
|
|
223
|
+
catch (error) {
|
|
224
|
+
spanUntrackedTrips?.recordException(error);
|
|
225
|
+
this.log.error(error,
|
|
226
|
+
// eslint-disable-next-line max-len
|
|
227
|
+
"Cannot retrieve untracked trips. The API consumer will receive departures with missing vehicles even if they requested to skip them.");
|
|
228
|
+
}
|
|
229
|
+
finally {
|
|
230
|
+
return untrackedTrips;
|
|
231
|
+
}
|
|
112
232
|
}
|
|
113
233
|
}
|
|
114
234
|
exports.PIDDepartureBoardsModel = PIDDepartureBoardsModel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PIDDepartureBoardsModel.js","sourceRoot":"","sources":["../../../../src/output-gateway/pid/models/PIDDepartureBoardsModel.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA0D;AAC1D,gDAA2D;
|
|
1
|
+
{"version":3,"file":"PIDDepartureBoardsModel.js","sourceRoot":"","sources":["../../../../src/output-gateway/pid/models/PIDDepartureBoardsModel.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA0D;AAC1D,gDAA2D;AAG3D,oDAA+C;AAO/C,wEAAqE;AACrE,+FAA6F;AAC7F,6EAA8F;AAC9F,gGAA2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IAAsI,CACzI,CAAC;SACL;gBAAS;YACN,OAAO,cAAc,CAAC;SACzB;IACL,CAAC;CACJ;AAEQ,0DAAuB"}
|
|
@@ -43,23 +43,34 @@ class PIDDeparturesModel {
|
|
|
43
43
|
*/
|
|
44
44
|
this.skip = () => {
|
|
45
45
|
this.departures = this.departures.filter((departure) => {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
let isCurrentTrip = false;
|
|
49
|
-
if ("arrival_datetime" in departure) {
|
|
50
|
-
isAtStop = departure.stop_sequence === departure["trip.last_position.this_stop_sequence"];
|
|
51
|
-
isPassStop =
|
|
52
|
-
!!departure["trip.last_position.last_stop_sequence"] &&
|
|
53
|
-
departure.stop_sequence <= departure["trip.last_position.last_stop_sequence"];
|
|
46
|
+
if (this.options.skip.length === 0) {
|
|
47
|
+
return true;
|
|
54
48
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
49
|
+
let isSkipUntracked = false;
|
|
50
|
+
let isSkipMissing = false;
|
|
51
|
+
let isSkipCanceled = false;
|
|
52
|
+
let isSkipAtStop = false;
|
|
53
|
+
for (const skip of this.options.skip) {
|
|
54
|
+
if (skip === pid_1.DepartureSkip.UNTRACKED) {
|
|
55
|
+
isSkipUntracked = true;
|
|
56
|
+
}
|
|
57
|
+
else if (skip === pid_1.DepartureSkip.MISSING) {
|
|
58
|
+
isSkipMissing = true;
|
|
59
|
+
}
|
|
60
|
+
else if (skip === pid_1.DepartureSkip.CANCELED) {
|
|
61
|
+
isSkipCanceled = true;
|
|
62
|
+
}
|
|
63
|
+
else if (skip === pid_1.DepartureSkip.AT_STOP) {
|
|
64
|
+
isSkipAtStop = true;
|
|
65
|
+
}
|
|
58
66
|
}
|
|
59
|
-
return !(
|
|
60
|
-
(
|
|
61
|
-
(
|
|
62
|
-
|
|
67
|
+
return !((this.options.tripNumber && SkipHelper_1.SkipHelper.isMatchingTripNumber(departure, this.options.tripNumber)) ||
|
|
68
|
+
(isSkipUntracked && SkipHelper_1.SkipHelper.hasNoDelayInfo(departure)) ||
|
|
69
|
+
(!isSkipUntracked &&
|
|
70
|
+
isSkipMissing &&
|
|
71
|
+
SkipHelper_1.SkipHelper.isVehicleMissing(departure, this.options.runScheduleMap, this.options.untrackedTrips)) ||
|
|
72
|
+
(isSkipCanceled && SkipHelper_1.SkipHelper.isTripCanceled(departure)) ||
|
|
73
|
+
(isSkipAtStop && SkipHelper_1.SkipHelper.isVehicleAtStop(departure)));
|
|
63
74
|
});
|
|
64
75
|
};
|
|
65
76
|
/** Sorts by proper datetime by given options
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PIDDepartureModel.js","sourceRoot":"","sources":["../../../../../src/output-gateway/pid/models/helpers/PIDDepartureModel.ts"],"names":[],"mappings":";;;;;AAAA,+BAQiB;AACjB,8FAAwE;AACxE,iDAAoE;AACpE,6CAA0C;AAG1C,MAAqB,kBAAkB;IAcnC,YAAY,UAA4B,EAAE,OAAkC;QAKrE,YAAO,GAAG,GAAoB,EAAE;YACnC,IAAI,CAAC,eAAe,EAAE,CAAC;YAEvB,OAAO,8BAAoB,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC9F,CAAC,CAAC;QASM,oBAAe,GAAG,CAAC,uBAAuB,GAAG,IAAI,EAAE,EAAE;YACzD,IAAI,CAAC,IAAI,EAAE,CAAC;YACZ,IAAI,CAAC,IAAI,EAAE,CAAC;YACZ,IAAI,CAAC,cAAc,EAAE,CAAC;YACtB,IAAI,CAAC,IAAI,EAAE,CAAC;YAEZ,IAAI,uBAAuB,EAAE;gBACzB,IAAI,CAAC,aAAa,EAAE,CAAC;aACxB;QACL,CAAC,CAAC;QAEF;WACG;QACK,mBAAc,GAAG,GAAS,EAAE;YAChC,MAAM,eAAe,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAEhD,IAAI,2BAAY,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;gBACpD,wEAAwE;gBACxE,IAAI,CAAC,UAAU,GAAG,eAAe,CAAC,IAAI;qBACjC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;qBAC5B,MAAM,CACH,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAChH;qBACA,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;aAC7E;iBAAM;gBACH,IAAI,CAAC,UAAU,GAAG,eAAe,CAAC,IAAI;qBACjC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;qBAC5B,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;aAC7E;QACL,CAAC,CAAC;QAEF;WACG;QACK,SAAI,GAAG,GAAS,EAAE;YACtB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE;gBACnD,IAAI,
|
|
1
|
+
{"version":3,"file":"PIDDepartureModel.js","sourceRoot":"","sources":["../../../../../src/output-gateway/pid/models/helpers/PIDDepartureModel.ts"],"names":[],"mappings":";;;;;AAAA,+BAQiB;AACjB,8FAAwE;AACxE,iDAAoE;AACpE,6CAA0C;AAG1C,MAAqB,kBAAkB;IAcnC,YAAY,UAA4B,EAAE,OAAkC;QAKrE,YAAO,GAAG,GAAoB,EAAE;YACnC,IA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,CAAC,gBAAgB,CAAC,CAAC;aACnC;iBAAM;gBACH,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;aACnC;YACD,OAAO,GAAG,CAAC;QACf,CAAC,EACD,EAAE,IAAI,EAAE,EAAsB,EAAE,IAAI,EAAE,EAAsB,EAAE,CACjE,CAAC;IACN,CAAC;;AA5Jc,qCAAkB,GAA8D;IAC3F,SAAS,EAAE,2BAAY,CAAC,kBAAkB;IAC1C,aAAa,EAAE,2BAAY,CAAC,kBAAkB;IAC9C,gBAAgB,EAAE,2BAAY,CAAC,yBAAyB;IACxD,oBAAoB,EAAE,2BAAY,CAAC,yBAAyB;IAC5D,qBAAqB,EAAE,2BAAY,CAAC,8BAA8B;IAClE,yBAAyB,EAAE,2BAAY,CAAC,8BAA8B;IACtE,IAAI,EAAE,SAAS;CAClB,AARgC,CAQ/B;kBAZe,kBAAkB"}
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import type { DepartureUnion } from "../..";
|
|
2
|
+
import type { IScheduleDto } from "../../../../schema-definitions/vehicle-positions/redis/interfaces/IGtfsRunTripCacheDto";
|
|
2
3
|
export declare class SkipHelper {
|
|
3
4
|
/**
|
|
4
5
|
* Used exclusively in transfer boards to skip transfers for the current trip
|
|
5
6
|
* (i.e., transfers within the vehicle where the transfer board is located)
|
|
6
7
|
*/
|
|
7
8
|
static isMatchingTripNumber(departure: DepartureUnion, tripNumber: string): boolean;
|
|
9
|
+
static hasNoDelayInfo(departure: DepartureUnion): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Used exclusively in departure boards when skip[]=missing is requested (without untracked)
|
|
12
|
+
*/
|
|
13
|
+
static isVehicleMissing(departure: DepartureUnion, runScheduleMap: Map<string, IScheduleDto[]> | null, untrackedTrips: Set<string> | null, nowDate?: Date): boolean;
|
|
14
|
+
static isTripCanceled(departure: DepartureUnion): boolean;
|
|
15
|
+
static isVehicleAtStop(departure: DepartureUnion): boolean;
|
|
16
|
+
private static isOutsideStartThreshold;
|
|
17
|
+
private static hasAlreadyDeparted;
|
|
18
|
+
private static hasLargeTimegapBetweenTrips;
|
|
8
19
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SkipHelper = void 0;
|
|
4
|
+
const RouteTypeEnums_1 = require("../../../../helpers/RouteTypeEnums");
|
|
5
|
+
const const_1 = require("./const");
|
|
4
6
|
/** Extracts the last numeric sequence from strings like:
|
|
5
7
|
* Os 1111 -> 1111
|
|
6
8
|
* Os 1111 B -> 1111
|
|
@@ -20,6 +22,95 @@ class SkipHelper {
|
|
|
20
22
|
const lastNumber = tripShortName.match(TRIP_NUMBER_REGEX)?.[1];
|
|
21
23
|
return !!lastNumber && lastNumber === tripNumber;
|
|
22
24
|
}
|
|
25
|
+
static hasNoDelayInfo(departure) {
|
|
26
|
+
return !departure.is_delay_available;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Used exclusively in departure boards when skip[]=missing is requested (without untracked)
|
|
30
|
+
*/
|
|
31
|
+
static isVehicleMissing(departure, runScheduleMap, untrackedTrips, nowDate = new Date()) {
|
|
32
|
+
// Not missing if essential trip data is missing or if delay information is available
|
|
33
|
+
if (!("trip.start_timestamp" in departure) ||
|
|
34
|
+
departure["trip.start_timestamp"] === null ||
|
|
35
|
+
departure.run_number === null ||
|
|
36
|
+
departure.origin_route_name === null ||
|
|
37
|
+
departure.is_delay_available) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
const startTimestamp = new Date(departure["trip.start_timestamp"]);
|
|
41
|
+
const minutesToStart = (startTimestamp.getTime() - nowDate.getTime()) / 60000;
|
|
42
|
+
/// Not missing if departure is too far in the future (threshold varies for metro)
|
|
43
|
+
if (this.isOutsideStartThreshold(minutesToStart, departure.route_type)) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
// Missing if the trip should have already started
|
|
47
|
+
else if (this.hasAlreadyDeparted(minutesToStart)) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
// Cannot determine missing status without run schedule information
|
|
51
|
+
const runId = `${departure.origin_route_name}_${departure.run_number}`;
|
|
52
|
+
const runSchedule = runScheduleMap?.get(runId);
|
|
53
|
+
if (!runSchedule) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
// Not missing if this is the first trip in the run or if trip isn't found
|
|
57
|
+
const runTripIndex = runSchedule.findIndex((trip) => trip.trip_id === departure.trip_id);
|
|
58
|
+
if (runTripIndex === -1 || runTripIndex === 0) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
// Not missing if there's a significant gap after the previous trip
|
|
62
|
+
const previousRunTripEnd = new Date(runSchedule[runTripIndex - 1].end_timestamp);
|
|
63
|
+
if (this.hasLargeTimegapBetweenTrips(previousRunTripEnd, startTimestamp)) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
// Not missing if the previous trip has delay information available
|
|
67
|
+
const isPreviousUntracked = untrackedTrips?.has(runSchedule[runTripIndex - 1].trip_id);
|
|
68
|
+
if (!isPreviousUntracked) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
const previousStartTimestamp = new Date(runSchedule[runTripIndex - 1].start_timestamp);
|
|
72
|
+
const previousMinutesToStart = (previousStartTimestamp.getTime() - nowDate.getTime()) / 60000;
|
|
73
|
+
// Missing if previous trip should have already started
|
|
74
|
+
if (this.hasAlreadyDeparted(previousMinutesToStart)) {
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
// Check position of previous trip in the run
|
|
78
|
+
const previousRunTripIndex = runTripIndex - 1;
|
|
79
|
+
if (previousRunTripIndex === -1 || previousRunTripIndex === 0) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
// Check for gaps before the previous trip
|
|
83
|
+
const previousPreviousRunTripEnd = new Date(runSchedule[previousRunTripIndex - 1].end_timestamp);
|
|
84
|
+
if (this.hasLargeTimegapBetweenTrips(previousPreviousRunTripEnd, previousStartTimestamp)) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
// If we reach here, the previous untracked trip is likely missing,
|
|
88
|
+
// which implies the current trip is also missing
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
static isTripCanceled(departure) {
|
|
92
|
+
return !!departure.is_canceled;
|
|
93
|
+
}
|
|
94
|
+
static isVehicleAtStop(departure) {
|
|
95
|
+
if (!("arrival_datetime" in departure)) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
const isAtStop = departure.stop_sequence === departure["trip.last_position.this_stop_sequence"];
|
|
99
|
+
const isPassStop = !!departure["trip.last_position.last_stop_sequence"] &&
|
|
100
|
+
departure.stop_sequence <= departure["trip.last_position.last_stop_sequence"];
|
|
101
|
+
return isAtStop || isPassStop;
|
|
102
|
+
}
|
|
103
|
+
static isOutsideStartThreshold(minutesToStart, routeType) {
|
|
104
|
+
const isMetro = routeType === RouteTypeEnums_1.GTFSRouteTypeEnum.METRO;
|
|
105
|
+
return isMetro ? minutesToStart >= const_1.START_SOON_METRO_MINUTES_THRESHOLD : minutesToStart >= const_1.START_SOON_MINUTES_THRESHOLD;
|
|
106
|
+
}
|
|
107
|
+
static hasAlreadyDeparted(minutesToStart) {
|
|
108
|
+
return minutesToStart < const_1.DEPARTURED_MINUTES_THRESHOLD;
|
|
109
|
+
}
|
|
110
|
+
static hasLargeTimegapBetweenTrips(endTimestamp, startTimestamp) {
|
|
111
|
+
const minutesAfterPrevious = (startTimestamp.getTime() - endTimestamp.getTime()) / 60000;
|
|
112
|
+
return minutesAfterPrevious >= const_1.TRIP_GAP_MINUTES_THRESHOLD;
|
|
113
|
+
}
|
|
23
114
|
}
|
|
24
115
|
exports.SkipHelper = SkipHelper;
|
|
25
116
|
//# sourceMappingURL=SkipHelper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SkipHelper.js","sourceRoot":"","sources":["../../../../../src/output-gateway/pid/models/helpers/SkipHelper.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"SkipHelper.js","sourceRoot":"","sources":["../../../../../src/output-gateway/pid/models/helpers/SkipHelper.ts"],"names":[],"mappings":";;;AAAA,uEAA4D;AAG5D,mCAKiB;AAEjB;;;;GAIG;AACH,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAE1C,MAAa,UAAU;IACnB;;;OAGG;IACI,MAAM,CAAC,oBAAoB,CAAC,SAAyB,EAAE,UAAkB;QAC5E,MAAM,aAAa,GAAG,SAAS,CAAC,eAAe,CAAC;QAChD,IAAI,CAAC,aAAa,EAAE;YAChB,OAAO,KAAK,CAAC;SAChB;QAED,MAAM,UAAU,GAAG,aAAa,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC/D,OAAO,CAAC,CAAC,UAAU,IAAI,UAAU,KAAK,UAAU,CAAC;IACrD,CAAC;IAEM,MAAM,CAAC,cAAc,CAAC,SAAyB;QAClD,OAAO,CAAC,SAAS,CAAC,kBAAkB,CAAC;IACzC,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,gBAAgB,CAC1B,SAAyB,EACzB,cAAkD,EAClD,cAAkC,EAClC,OAAO,GAAG,IAAI,IAAI,EAAE;QAEpB,qFAAqF;QACrF,IACI,CAAC,CAAC,sBAAsB,IAAI,SAAS,CAAC;YACtC,SAAS,CAAC,sBAAsB,CAAC,KAAK,IAAI;YAC1C,SAAS,CAAC,UAAU,KAAK,IAAI;YAC7B,SAAS,CAAC,iBAAiB,KAAK,IAAI;YACpC,SAAS,CAAC,kBAAkB,EAC9B;YACE,OAAO,KAAK,CAAC;SAChB;QAED,MAAM,cAAc,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,sBAAsB,CAAC,CAAC,CAAC;QACnE,MAAM,cAAc,GAAG,CAAC,cAAc,CAAC,OAAO,EAAE,GAAG,OA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AM,OAAO,GAAG,SAAS,KAAK,kCAAiB,CAAC,KAAK,CAAC;QACtD,OAAO,OAAO,CAAC,CAAC,CAAC,cAAc,IAAI,0CAAkC,CAAC,CAAC,CAAC,cAAc,IAAI,oCAA4B,CAAC;IAC3H,CAAC;IAEO,MAAM,CAAC,kBAAkB,CAAC,cAAsB;QACpD,OAAO,cAAc,GAAG,oCAA4B,CAAC;IACzD,CAAC;IAEO,MAAM,CAAC,2BAA2B,CAAC,YAAkB,EAAE,cAAoB;QAC/E,MAAM,oBAAoB,GAAG,CAAC,cAAc,CAAC,OAAO,EAAE,GAAG,YAAY,CAAC,OAAO,EAAE,CAAC,GAAG,KAAK,CAAC;QACzF,OAAO,oBAAoB,IAAI,kCAA0B,CAAC;IAC9D,CAAC;CACJ;AAnID,gCAmIC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TRIP_GAP_MINUTES_THRESHOLD = exports.DEPARTURED_MINUTES_THRESHOLD = exports.START_SOON_METRO_MINUTES_THRESHOLD = exports.START_SOON_MINUTES_THRESHOLD = void 0;
|
|
4
|
+
exports.START_SOON_MINUTES_THRESHOLD = 30;
|
|
5
|
+
exports.START_SOON_METRO_MINUTES_THRESHOLD = 5;
|
|
6
|
+
exports.DEPARTURED_MINUTES_THRESHOLD = -2;
|
|
7
|
+
exports.TRIP_GAP_MINUTES_THRESHOLD = 60;
|
|
8
|
+
//# sourceMappingURL=const.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"const.js","sourceRoot":"","sources":["../../../../../src/output-gateway/pid/models/helpers/const.ts"],"names":[],"mappings":";;;AAAa,QAAA,4BAA4B,GAAG,EAAE,CAAC;AAClC,QAAA,kCAAkC,GAAG,CAAC,CAAC;AACvC,QAAA,4BAA4B,GAAG,CAAC,CAAC,CAAC;AAClC,QAAA,0BAA0B,GAAG,EAAE,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DepartureFilter, DepartureMode, DepartureOrder, DepartureSkip } from "../../..";
|
|
2
2
|
import { IRopidDeparturesDirectionsOutput } from "../../../../../schema-definitions/ropid-departures-directions";
|
|
3
|
+
import { IScheduleDto } from "../../../../../schema-definitions/vehicle-positions/redis/interfaces/IGtfsRunTripCacheDto";
|
|
3
4
|
export default interface IPIDDepartureQueryOptions {
|
|
4
5
|
limit: number;
|
|
5
6
|
offset: number;
|
|
@@ -11,4 +12,6 @@ export default interface IPIDDepartureQueryOptions {
|
|
|
11
12
|
departuresDirections: IRopidDeparturesDirectionsOutput[];
|
|
12
13
|
timezone: string;
|
|
13
14
|
tripNumber: string | null;
|
|
15
|
+
runScheduleMap: Map<string, IScheduleDto[]> | null;
|
|
16
|
+
untrackedTrips: Set<string> | null;
|
|
14
17
|
}
|