@golemio/pid 3.5.0 → 3.5.1-dev.1632495980
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/sqls/20250103092631-skip-missing-down.sql +184 -0
- package/db/migrations/postgresql/sqls/20250103092631-skip-missing-up.sql +195 -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/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/controllers/v3/V3TransferBoardsController.d.ts +1 -0
- package/dist/output-gateway/pid/controllers/v3/V3TransferBoardsController.js +12 -3
- package/dist/output-gateway/pid/controllers/v3/V3TransferBoardsController.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 -71
- package/dist/output-gateway/pid/models/PIDDepartureBoardsModel.js.map +1 -1
- package/dist/output-gateway/pid/models/helpers/PIDDepartureModel.js +27 -15
- package/dist/output-gateway/pid/models/helpers/PIDDepartureModel.js.map +1 -1
- package/dist/output-gateway/pid/models/helpers/SkipHelper.d.ts +19 -0
- package/dist/output-gateway/pid/models/helpers/SkipHelper.js +116 -0
- package/dist/output-gateway/pid/models/helpers/SkipHelper.js.map +1 -0
- 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 +4 -1
- 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/routers/v3/V3PIDRouter.js +1 -1
- package/dist/output-gateway/pid/routers/v3/V3PIDRouter.js.map +1 -1
- package/dist/output-gateway/pid/service/facade/TransferFacade.d.ts +1 -1
- 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 +11 -3
- package/package.json +3 -3
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OgPidContainer = void 0;
|
|
4
|
+
const PublicVehiclePositionsRepository_1 = require("../../public/data-access/redis/PublicVehiclePositionsRepository");
|
|
4
5
|
const CisStopGroupRepository_1 = require("../../ropid-gtfs/data-access/CisStopGroupRepository");
|
|
6
|
+
const RunTripsRedisRepository_1 = require("../../ropid-gtfs/data-access/redis/RunTripsRedisRepository");
|
|
5
7
|
const ioc_1 = require("@golemio/core/dist/output-gateway/ioc");
|
|
6
8
|
const V3InfotextsController_1 = require("../controllers/v3/V3InfotextsController");
|
|
7
9
|
const V3TransferBoardsController_1 = require("../controllers/v3/V3TransferBoardsController");
|
|
@@ -24,6 +26,8 @@ ogPidContainer.registerSingleton(OgPidToken_1.OgPidToken.JISInfotextRopidGTFSSto
|
|
|
24
26
|
ogPidContainer.registerSingleton(OgPidToken_1.OgPidToken.JISInfotextRopidGTFSStopsRepository, JISInfotextRopidGTFSStopsRepository_1.JISInfotextRopidGTFSStopsRepository);
|
|
25
27
|
ogPidContainer.registerSingleton(OgPidToken_1.OgPidToken.JISInfotextRepository, JISInfotextRepository_1.JISInfotextRepository);
|
|
26
28
|
ogPidContainer.registerSingleton(OgPidToken_1.OgPidToken.DeparturesRepository, data_access_1.DeparturesRepository);
|
|
29
|
+
ogPidContainer.registerSingleton(OgPidToken_1.OgPidToken.RunTripsRedisRepository, RunTripsRedisRepository_1.RunTripsRedisRepository);
|
|
30
|
+
ogPidContainer.registerSingleton(OgPidToken_1.OgPidToken.PublicVehiclePositionsRepository, PublicVehiclePositionsRepository_1.PublicVehiclePositionsRepository);
|
|
27
31
|
//#endregion
|
|
28
32
|
//#region Transformations
|
|
29
33
|
ogPidContainer.registerSingleton(OgPidToken_1.OgPidToken.JISInfotextDepartureTransformation, JISInfotextDepartureTransformation_1.JISInfotextDepartureTransformation);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Di.js","sourceRoot":"","sources":["../../../../src/output-gateway/pid/ioc/Di.ts"],"names":[],"mappings":";;;AAAA,gGAA2F;AAC3F,+DAA+E;AAE/E,mFAAgF;AAChF,6FAA0F;AAC1F,gDAAsD;AACtD,gFAA6E;AAC7E,4GAAyG;AACzG,qEAAkE;AAClE,6DAA0D;AAC1D,qEAAkE;AAClE,sHAAmH;AACnH,oHAAiH;AACjH,oHAAiH;AACjH,gHAA6G;AAC7G,6CAA0C;AAE1C,MAAM,cAAc,GAAwB,4BAAsB,CAAC,oBAAoB,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"Di.js","sourceRoot":"","sources":["../../../../src/output-gateway/pid/ioc/Di.ts"],"names":[],"mappings":";;;AAAA,sHAAiH;AACjH,gGAA2F;AAC3F,wGAAmG;AACnG,+DAA+E;AAE/E,mFAAgF;AAChF,6FAA0F;AAC1F,gDAAsD;AACtD,gFAA6E;AAC7E,4GAAyG;AACzG,qEAAkE;AAClE,6DAA0D;AAC1D,qEAAkE;AAClE,sHAAmH;AACnH,oHAAiH;AACjH,oHAAiH;AACjH,gHAA6G;AAC7G,6CAA0C;AAE1C,MAAM,cAAc,GAAwB,4BAAsB,CAAC,oBAAoB,EAAE,CAAC;AA8B/D,wCAAc;AA5BzC,sBAAsB;AACtB,cAAc,CAAC,iBAAiB,CAAC,uBAAU,CAAC,s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AC,CAAC;AACpG,cAAc,CAAC,iBAAiB,CAAC,uBAAU,CAAC,qBAAqB,EAAE,6CAAqB,CAAC,CAAC"}
|
|
@@ -3,6 +3,8 @@ export declare const OgPidToken: {
|
|
|
3
3
|
JISInfotextRopidGTFSStopsRepository: symbol;
|
|
4
4
|
JISInfotextRepository: symbol;
|
|
5
5
|
DeparturesRepository: symbol;
|
|
6
|
+
RunTripsRedisRepository: symbol;
|
|
7
|
+
PublicVehiclePositionsRepository: symbol;
|
|
6
8
|
JISInfotextDepartureTransformation: symbol;
|
|
7
9
|
JISInfotextTransferTransformation: symbol;
|
|
8
10
|
JISInfotextOverviewTransformation: symbol;
|
|
@@ -7,6 +7,8 @@ exports.OgPidToken = {
|
|
|
7
7
|
JISInfotextRopidGTFSStopsRepository: Symbol(),
|
|
8
8
|
JISInfotextRepository: Symbol(),
|
|
9
9
|
DeparturesRepository: Symbol(),
|
|
10
|
+
RunTripsRedisRepository: Symbol(),
|
|
11
|
+
PublicVehiclePositionsRepository: Symbol(),
|
|
10
12
|
//#endregion
|
|
11
13
|
//#region Transformations
|
|
12
14
|
JISInfotextDepartureTransformation: Symbol(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OgPidToken.js","sourceRoot":"","sources":["../../../../src/output-gateway/pid/ioc/OgPidToken.ts"],"names":[],"mappings":";;;AAAa,QAAA,UAAU,GAAG;IACtB,sBAAsB;IACtB,sBAAsB,EAAE,MAAM,EAAE;IAChC,mCAAmC,EAAE,MAAM,EAAE;IAC7C,qBAAqB,EAAE,MAAM,EAAE;IAC/B,oBAAoB,EAAE,MAAM,EAAE;IAC9B,YAAY;IAEZ,yBAAyB;IACzB,kCAAkC,EAAE,MAAM,EAAE;IAC5C,iCAAiC,EAAE,MAAM,EAAE;IAC3C,iCAAiC,EAAE,MAAM,EAAE;IAC3C,+BAA+B,EAAE,MAAM,EAAE;IACzC,YAAY;IAEZ,gBAAgB;IAChB,UAAU,EAAE,MAAM,EAAE;IACpB,cAAc,EAAE,MAAM,EAAE;IACxB,cAAc,EAAE,MAAM,EAAE;IACxB,YAAY;IAEZ,qBAAqB;IACrB,0BAA0B,EAAE,MAAM,EAAE;IACpC,qBAAqB,EAAE,MAAM,EAAE;IAC/B,YAAY;CACf,CAAC"}
|
|
1
|
+
{"version":3,"file":"OgPidToken.js","sourceRoot":"","sources":["../../../../src/output-gateway/pid/ioc/OgPidToken.ts"],"names":[],"mappings":";;;AAAa,QAAA,UAAU,GAAG;IACtB,sBAAsB;IACtB,sBAAsB,EAAE,MAAM,EAAE;IAChC,mCAAmC,EAAE,MAAM,EAAE;IAC7C,qBAAqB,EAAE,MAAM,EAAE;IAC/B,oBAAoB,EAAE,MAAM,EAAE;IAC9B,uBAAuB,EAAE,MAAM,EAAE;IACjC,gCAAgC,EAAE,MAAM,EAAE;IAC1C,YAAY;IAEZ,yBAAyB;IACzB,kCAAkC,EAAE,MAAM,EAAE;IAC5C,iCAAiC,EAAE,MAAM,EAAE;IAC3C,iCAAiC,EAAE,MAAM,EAAE;IAC3C,+BAA+B,EAAE,MAAM,EAAE;IACzC,YAAY;IAEZ,gBAAgB;IAChB,UAAU,EAAE,MAAM,EAAE;IACpB,cAAc,EAAE,MAAM,EAAE;IACxB,cAAc,EAAE,MAAM,EAAE;IACxB,YAAY;IAEZ,qBAAqB;IACrB,0BAA0B,EAAE,MAAM,EAAE;IACpC,qBAAqB,EAAE,MAAM,EAAE;IAC/B,YAAY;CACf,CAAC"}
|
|
@@ -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,102 +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
|
-
}).toArray(),
|
|
97
|
-
infotexts: infotextsToInclude,
|
|
98
|
-
stops: stopsToInclude,
|
|
99
|
-
};
|
|
100
|
-
spanDepartures?.end();
|
|
101
|
-
return res;
|
|
148
|
+
return departuresDirections;
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
spanDirections?.recordException(error);
|
|
152
|
+
if (error instanceof golemio_errors_1.AbstractGolemioError) {
|
|
153
|
+
throw error;
|
|
102
154
|
}
|
|
103
|
-
|
|
104
|
-
|
|
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;
|
|
105
179
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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
|
+
}
|
|
111
232
|
}
|
|
112
233
|
}
|
|
113
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,gGAA2E;AAC3E,wBAAmD;AACnD,0BAAkD;AAIlD,kCAA2C;AAC3C,kDAA+C;AAE/C,oFAA6D;AAG7D,MAAM,eAAe,GAAG,GAAG,CAAC;AAE5B,0EAA0E;AAC1E,sEAAsE;AACtE,MAAM,uBAAuB;IASzB;QACI,IAAI,CAAC,GAAG,GAAG,mBAAc,CAAC,OAAO,CAAU,qBAAS,CAAC,MAAM,CAAC,CAAC;QAC7D,IAAI,CAAC,8BAA8B,GAAG,IAAI,iCAA8B,EAAE,CAAC;QAC3E,IAAI,CAAC,oBAAoB,GAAG,IAAI,kCAAoB,CAChD,mBAAc,CAAC,OAAO,CAAqB,qBAAS,CAAC,iBAAiB,CAAC,EACvE,mBAAc,CAAC,OAAO,CAAgB,qBAAS,CAAC,YAAY,CAAC,CAChE,CAAC;QACF,IAAI,CAAC,uBAAuB,GAAG,mBAAc,CAAC,OAAO,CAA2B,uBAAU,CAAC,uBAAuB,CAAC,CAAC;QACpH,IAAI,CAAC,wBAAwB,GAAG,mBAAc,CAAC,OAAO,CAClD,uBAAU,CAAC,gCAAgC,CAC9C,CAAC;QACF,IAAI,CAAC,kBAAkB,GAAG,mBAAc,CAAC,OAAO,CAAwB,uBAAU,CAAC,qBAAqB,CAAC,CAAC;QAC1G,IAAI,CAAC,sBAAsB,GAAG,mBAAc,CAAC,OAAO,CAChD,uBAAU,CAAC,kCAAkC,CAChD,CAAC;IACN,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,OAA8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GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACzC,cAAc,GAAG,MAAM,IAAI,CAAC,wBAAwB,CAAC,6BAA6B,CAAC,YAAY,CAAC,CAAC;YACjG,kBAAkB,EAAE,GAAG,EAAE,CAAC;SAC7B;QAAC,OAAO,KAAK,EAAE;YACZ,kBAAkB,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC;YAC3C,IAAI,CAAC,GAAG,CAAC,KAAK,CACV,KAAK;YACL,mCAAmC;YACnC,sIAAsI,CACzI,CAAC;SACL;gBAAS;YACN,OAAO,cAAc,CAAC;SACzB;IACL,CAAC;CACJ;AAEQ,0DAAuB"}
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const pid_1 = require("../..");
|
|
7
7
|
const DepartureBoardMapper_1 = __importDefault(require("../../helpers/DepartureBoardMapper"));
|
|
8
8
|
const FilterHelper_1 = require("./FilterHelper");
|
|
9
|
+
const SkipHelper_1 = require("./SkipHelper");
|
|
9
10
|
class PIDDeparturesModel {
|
|
10
11
|
constructor(departures, options) {
|
|
11
12
|
this.toArray = () => {
|
|
@@ -42,23 +43,34 @@ class PIDDeparturesModel {
|
|
|
42
43
|
*/
|
|
43
44
|
this.skip = () => {
|
|
44
45
|
this.departures = this.departures.filter((departure) => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
let isCurrentTrip = false;
|
|
48
|
-
if ("arrival_datetime" in departure) {
|
|
49
|
-
isAtStop = departure.stop_sequence === departure["trip.last_position.this_stop_sequence"];
|
|
50
|
-
isPassStop =
|
|
51
|
-
!!departure["trip.last_position.last_stop_sequence"] &&
|
|
52
|
-
departure.stop_sequence <= departure["trip.last_position.last_stop_sequence"];
|
|
46
|
+
if (this.options.skip.length === 0) {
|
|
47
|
+
return true;
|
|
53
48
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
+
}
|
|
57
66
|
}
|
|
58
|
-
return !(
|
|
59
|
-
(
|
|
60
|
-
(
|
|
61
|
-
|
|
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)));
|
|
62
74
|
});
|
|
63
75
|
};
|
|
64
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;
|
|
1
|
+
{"version":3,"file":"PIDDepartureModel.js","sourceRoot":"","sources":["../../../../../src/output-gateway/pid/models/helpers/PIDDep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QAC7D,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CACzB,CAAC,GAAG,EAAE,gBAAgB,EAAE,EAAE;YACtB,IAAI,iBAAiB,CAAC,GAAG,EAAE,gBAAgB,CAAC,EAAE;gBAC1C,GAAG,CAAC,IAAI,CAAC,IAAI,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"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { DepartureUnion } from "../..";
|
|
2
|
+
import type { IScheduleDto } from "../../../../schema-definitions/vehicle-positions/redis/interfaces/IGtfsRunTripCacheDto";
|
|
3
|
+
export declare class SkipHelper {
|
|
4
|
+
/**
|
|
5
|
+
* Used exclusively in transfer boards to skip transfers for the current trip
|
|
6
|
+
* (i.e., transfers within the vehicle where the transfer board is located)
|
|
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;
|
|
19
|
+
}
|