@golemio/pid 2.13.6-dev.1313748965 → 2.13.6
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/dist/integration-engine/vehicle-positions/workers/runs/helpers/regional-bus/RegionalBusMessageFilter.d.ts +4 -1
- package/dist/integration-engine/vehicle-positions/workers/runs/helpers/regional-bus/RegionalBusMessageFilter.js +27 -11
- package/dist/integration-engine/vehicle-positions/workers/runs/helpers/regional-bus/RegionalBusMessageFilter.js.map +1 -1
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/tasks/RefreshPublicStopTimeCacheTask.d.ts +1 -0
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/tasks/RefreshPublicStopTimeCacheTask.js +1 -0
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/tasks/RefreshPublicStopTimeCacheTask.js.map +1 -1
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/transformations/MpvMessageTransformation.d.ts +6 -3
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/transformations/MpvMessageTransformation.js +19 -8
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/transformations/MpvMessageTransformation.js.map +1 -1
- package/docs/implementation_documentation.md +4 -0
- package/docs/openapi-output.yaml +200 -2
- package/package.json +3 -3
- package/db/migrations/postgresql/20240523123717-add-stop-name-and-gps-to-history-data.js +0 -53
- package/db/migrations/postgresql/sqls/20240523123717-add-stop-name-and-gps-to-history-data-down.sql +0 -107
- package/db/migrations/postgresql/sqls/20240523123717-add-stop-name-and-gps-to-history-data-up.sql +0 -118
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { IRegionalBusRunsMessagesModel } from "../../../../../../schema-definitions/vehicle-positions/models/interfaces/IRegionalBusRunsMessagesModel";
|
|
2
|
+
import { ISimpleConfig } from "@golemio/core/dist/helpers/configuration/ISimpleConfig";
|
|
2
3
|
import { ILogger } from "@golemio/core/dist/helpers/logger";
|
|
3
4
|
import { IRegionalBusMessageFilter } from "./interfaces/IRegionalBusMessageFilter";
|
|
4
5
|
import { TimestampValidator } from "../TimestampValidator";
|
|
5
6
|
export declare class RegionalBusMessageFilter implements IRegionalBusMessageFilter {
|
|
7
|
+
private config;
|
|
6
8
|
private logger;
|
|
7
9
|
private timestampValidator;
|
|
8
|
-
constructor(logger: ILogger, timestampValidator: TimestampValidator);
|
|
10
|
+
constructor(config: ISimpleConfig, logger: ILogger, timestampValidator: TimestampValidator);
|
|
9
11
|
/**
|
|
10
12
|
* Get messages that are valid for processing
|
|
11
13
|
*/
|
|
12
14
|
getFilteredMessages(messages: IRegionalBusRunsMessagesModel[], timestamp: number): IRegionalBusRunsMessagesModel[];
|
|
15
|
+
private get regNumberWhitelist();
|
|
13
16
|
}
|
|
@@ -19,7 +19,8 @@ const VPContainerToken_1 = require("../../../../ioc/VPContainerToken");
|
|
|
19
19
|
const TimestampValidator_1 = require("../TimestampValidator");
|
|
20
20
|
const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
|
|
21
21
|
let RegionalBusMessageFilter = exports.RegionalBusMessageFilter = class RegionalBusMessageFilter {
|
|
22
|
-
constructor(logger, timestampValidator) {
|
|
22
|
+
constructor(config, logger, timestampValidator) {
|
|
23
|
+
this.config = config;
|
|
23
24
|
this.logger = logger;
|
|
24
25
|
this.timestampValidator = timestampValidator;
|
|
25
26
|
}
|
|
@@ -29,13 +30,18 @@ let RegionalBusMessageFilter = exports.RegionalBusMessageFilter = class Regional
|
|
|
29
30
|
getFilteredMessages(messages, timestamp) {
|
|
30
31
|
let filteredMessages = [];
|
|
31
32
|
for (const message of messages) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
if (message.cis_line_id && message.cis_trip_number && message.registration_number && message.events !== "") {
|
|
34
|
+
if (this.regNumberWhitelist && !this.regNumberWhitelist.includes(message.registration_number.toString())) {
|
|
35
|
+
this.logger.verbose(
|
|
36
|
+
// eslint-disable-next-line max-len
|
|
37
|
+
`getFilteredMessages: message with registration_number=${message.registration_number} is not in whitelist, skipping`);
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (!this.timestampValidator.isTimestampValid(timestamp, message.timestamp)) {
|
|
41
|
+
this.logger.error(new golemio_errors_1.GeneralError(`Message timestamp 'tm' of value ${message.timestamp} is not valid ` +
|
|
42
|
+
`(line ${message.cis_line_id}, trip id ${message.cis_trip_number})`, this.constructor.name, undefined, undefined, "pid"));
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
39
45
|
filteredMessages.push(message);
|
|
40
46
|
}
|
|
41
47
|
}
|
|
@@ -44,11 +50,21 @@ let RegionalBusMessageFilter = exports.RegionalBusMessageFilter = class Regional
|
|
|
44
50
|
}
|
|
45
51
|
return filteredMessages;
|
|
46
52
|
}
|
|
53
|
+
get regNumberWhitelist() {
|
|
54
|
+
const valuePath = "old.datasources.pid.vehicle-positions.regNumberWhitelist.regionalBus";
|
|
55
|
+
const whitelistDict = this.config.getValue(valuePath, {});
|
|
56
|
+
const whitelist = Object.values(whitelistDict);
|
|
57
|
+
if (whitelist[0] !== "*") {
|
|
58
|
+
return whitelist;
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
47
62
|
};
|
|
48
63
|
exports.RegionalBusMessageFilter = RegionalBusMessageFilter = __decorate([
|
|
49
64
|
(0, tsyringe_1.injectable)(),
|
|
50
|
-
__param(0, (0, tsyringe_1.inject)(CoreToken_1.CoreToken.
|
|
51
|
-
__param(1, (0, tsyringe_1.inject)(
|
|
52
|
-
|
|
65
|
+
__param(0, (0, tsyringe_1.inject)(CoreToken_1.CoreToken.SimpleConfig)),
|
|
66
|
+
__param(1, (0, tsyringe_1.inject)(CoreToken_1.CoreToken.Logger)),
|
|
67
|
+
__param(2, (0, tsyringe_1.inject)(VPContainerToken_1.VPContainerToken.TimestampValidator)),
|
|
68
|
+
__metadata("design:paramtypes", [Object, Object, TimestampValidator_1.TimestampValidator])
|
|
53
69
|
], RegionalBusMessageFilter);
|
|
54
70
|
//# sourceMappingURL=RegionalBusMessageFilter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegionalBusMessageFilter.js","sourceRoot":"","sources":["../../../../../../../src/integration-engine/vehicle-positions/workers/runs/helpers/regional-bus/RegionalBusMessageFilter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"RegionalBusMessageFilter.js","sourceRoot":"","sources":["../../../../../../../src/integration-engine/vehicle-positions/workers/runs/helpers/regional-bus/RegionalBusMessageFilter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,wEAAqE;AAErE,iEAAwE;AAExE,uEAA8E;AAC9E,8DAA2D;AAC3D,6EAAwE;AAGjE,IAAM,wBAAwB,sCAA9B,MAAM,wBAAwB;IACjC,YAC4C,MAAqB,EAC3B,MAAe,EACI,kBAAsC;QAFnD,WAAM,GAAN,MAAM,CAAe;QAC3B,WAAM,GAAN,MAAM,CAAS;QACI,uBAAkB,GAAlB,kBAAkB,CAAoB;IAC5F,CAAC;IAEJ;;OAEG;IACI,mBAAmB,CAAC,QAAyC,EAAE,SAAiB;QACnF,IAAI,gBAAgB,GAAoC,EAAE,CAAC;QAC3D,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;YAC5B,IAAI,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,eAAe,IAAI,OAAO,CAAC,mBAAmB,IAAI,OAAO,CAAC,MAAM,KAAK,EAAE,EAAE;gBACxG,IAAI,IAAI,CAAC,kBAAkB,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,OAAO,CAAC,mBAAmB,CAAC,QAAQ,EAAE,CAAC,EAAE;oBACtG,IAAI,CAAC,MAAM,CAAC,OAAO;oBACf,mCAAmC;oBACnC,yDAAyD,OAAO,CAAC,mBAAmB,gCAAgC,CACvH,CAAC;oBACF,SAA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 -13,6 +13,7 @@ export declare class RefreshPublicStopTimeCacheTask extends AbstractEmptyTask {
|
|
|
13
13
|
readonly queueTtl = 10000;
|
|
14
14
|
private lockTimeout;
|
|
15
15
|
private refreshInterval;
|
|
16
|
+
private vehicleIdGenerator;
|
|
16
17
|
constructor(config: ISimpleConfig, logger: ILogger, redisClient: IoRedisConnector, publicStopTimeRepository: PublicStopTimeRepository, publicStopTimeCacheRepository: PublicStopTimeCacheRepository);
|
|
17
18
|
protected execute(): Promise<void>;
|
|
18
19
|
private createMutex;
|
|
@@ -48,6 +48,7 @@ let RefreshPublicStopTimeCacheTask = exports.RefreshPublicStopTimeCacheTask = cl
|
|
|
48
48
|
this.queueTtl = 10000; // 10s
|
|
49
49
|
this.lockTimeout = config.getValue("old.datasources.pid.vehicle-positions.publicCache.mutexLockStopTimeTimeout", 6000); // default 6s
|
|
50
50
|
this.refreshInterval = this.lockTimeout * 0.8;
|
|
51
|
+
this.vehicleIdGenerator = new VehicleIdGenerator_1.VehicleIdGenerator();
|
|
51
52
|
}
|
|
52
53
|
execute() {
|
|
53
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RefreshPublicStopTimeCacheTask.js","sourceRoot":"","sources":["../../../../../../src/integration-engine/vehicle-positions/workers/vehicle-positions/tasks/RefreshPublicStopTimeCacheTask.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,oEAA8E;AAG9E,oGAAiG;AACjG,wEAAqE;AAErE,8EAAqE;AACrE,mEAA2E;AAC3E,2EAAkF;AAClF,6EAA8F;AAC9F,+EAAkE;AAClE,iEAAwE;AACxE,mDAA2D;AAC3D,4CAA2C;AAC3C,sGAAmG;AACnG,4FAAyF;AACzF,gDAA6C;AAC7C,iFAAsG;AAG/F,IAAM,8BAA8B,4CAApC,MAAM,8BAA+B,SAAQ,2BAAiB;
|
|
1
|
+
{"version":3,"file":"RefreshPublicStopTimeCacheTask.js","sourceRoot":"","sources":["../../../../../../src/integration-engine/vehicle-positions/workers/vehicle-positions/tasks/RefreshPublicStopTimeCacheTask.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,oEAA8E;AAG9E,oGAAiG;AACjG,wEAAqE;AAErE,8EAAqE;AACrE,mEAA2E;AAC3E,2EAAkF;AAClF,6EAA8F;AAC9F,+EAAkE;AAClE,iEAAwE;AACxE,mDAA2D;AAC3D,4CAA2C;AAC3C,sGAAmG;AACnG,4FAAyF;AACzF,gDAA6C;AAC7C,iFAAsG;AAG/F,IAAM,8BAA8B,4CAApC,MAAM,8BAA+B,SAAQ,2BAAiB;IAOjE,YACoC,MAAqB,EAC3B,MAAuB,EACV,WAAqC,EAE5E,wBAA0D,EAE1D,6BAAoE;QAEpE,KAAK,CAAC,uBAAW,CAAC,CAAC;QAPe,WAAM,GAAN,MAAM,CAAS;QACF,gBAAW,GAAX,WAAW,CAAkB;QAEpE,6BAAwB,GAAxB,wBAAwB,CAA0B;QAElD,kCAA6B,GAA7B,6BAA6B,CAA+B;QAbxD,cAAS,GAAG,4BAA4B,CAAC;QACzC,aAAQ,GAAG,KAAK,CAAC,CAAC,MAAM;QAepC,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,QAAQ,CAC9B,4EAA4E,EAC5E,IAAI,CACG,CAAC,CAAC,aAAa;QAC1B,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,WAAW,GAAG,GAAG,CAAC;QAC9C,IAAI,CAAC,kBAAkB,GAAG,IAAI,uCAAkB,EAAE,CAAC;IACvD,CAAC;IAEe,OAAO;;YACnB,MAAM,aAAa,GAAG,IAAI,IAAI,EAAE,CAAC;YACjC,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;YACjC,MAAM,YAAY,GAAG,MAAM,KAAK,CAAC,UAAU,EAAE,CAAC;YAE9C,IAAI,CAAC,YAAY,EAAE;gBACf,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GA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,EAAC,qBAAS,CAAC,YAAY,CAAC,CAAA;IAC9B,WAAA,IAAA,iBAAM,EAAC,qBAAS,CAAC,MAAM,CAAC,CAAA;IACxB,WAAA,IAAA,iBAAM,EAAC,oBAAc,CAAC,cAAc,CAAC,CAAA;IACrC,WAAA,IAAA,iBAAM,EAAC,mCAAgB,CAAC,wBAAwB,CAAC,CAAA;IAEjD,WAAA,IAAA,iBAAM,EAAC,mCAAgB,CAAC,6BAA6B,CAAC,CAAA;qDAHK,mCAAgB;QAE1C,mDAAwB;QAEnB,6DAA6B;GAd/D,8BAA8B,CAuG1C"}
|
|
@@ -3,10 +3,9 @@ import { Moment } from "@golemio/core/dist/shared/moment-timezone";
|
|
|
3
3
|
import { IMpvPositionContent } from "../../../../../schema-definitions/vehicle-positions/interfaces/IMpvMessageInterfaces";
|
|
4
4
|
import { ITransformationElement, ITransformationResult } from "../interfaces/TransformationInterfaces";
|
|
5
5
|
export declare class MpvMessageTransformation extends BaseTransformation implements ITransformation {
|
|
6
|
-
private static ORIGIN_TIME_FORMAT;
|
|
7
6
|
name: string;
|
|
8
7
|
private config;
|
|
9
|
-
private
|
|
8
|
+
private static ORIGIN_TIME_FORMAT;
|
|
10
9
|
constructor();
|
|
11
10
|
/**
|
|
12
11
|
* Overrides BaseTransformation::transform
|
|
@@ -32,7 +31,6 @@ export declare class MpvMessageTransformation extends BaseTransformation impleme
|
|
|
32
31
|
* @returns {number}
|
|
33
32
|
*/
|
|
34
33
|
private checkMidnight;
|
|
35
|
-
private isBlacklistedAgency;
|
|
36
34
|
/**
|
|
37
35
|
* Fix source negative bearing value due to overflow by adding 256
|
|
38
36
|
*
|
|
@@ -47,4 +45,9 @@ export declare class MpvMessageTransformation extends BaseTransformation impleme
|
|
|
47
45
|
* @returns {stringList}
|
|
48
46
|
*/
|
|
49
47
|
private formatASWStopId;
|
|
48
|
+
/**
|
|
49
|
+
* Returns list of vehicle reg numbers that should be excluded from MPVNet processing
|
|
50
|
+
* (already processed from another source)
|
|
51
|
+
*/
|
|
52
|
+
private get regionalBusRegNumberBlacklist();
|
|
50
53
|
}
|
|
@@ -31,7 +31,6 @@ var PositionTrackingEnum;
|
|
|
31
31
|
class MpvMessageTransformation extends transformations_1.BaseTransformation {
|
|
32
32
|
constructor() {
|
|
33
33
|
super();
|
|
34
|
-
this.skipAgencyNames = [DPPUtils_1.default.DPP_AGENCY_NAME];
|
|
35
34
|
/**
|
|
36
35
|
* Overrides BaseTransformation::transform
|
|
37
36
|
*/
|
|
@@ -62,9 +61,14 @@ class MpvMessageTransformation extends transformations_1.BaseTransformation {
|
|
|
62
61
|
this.transformElement = (element) => __awaiter(this, void 0, void 0, function* () {
|
|
63
62
|
var _a, _b;
|
|
64
63
|
const attributes = element.$;
|
|
64
|
+
// DPP and regional bus trips to be excluded in HTTP ingress
|
|
65
|
+
const isDPPTrip = attributes.dopr === DPPUtils_1.default.DPP_AGENCY_NAME;
|
|
66
|
+
const isRegionalBusTrip = !!attributes.vuzevc &&
|
|
67
|
+
this.regionalBusRegNumberBlacklist &&
|
|
68
|
+
this.regionalBusRegNumberBlacklist.includes(attributes.vuzevc);
|
|
65
69
|
// Trips with null cpoz (origin time) and falsy or "false" zrus (cancellation) attributes are excluded
|
|
66
70
|
const hasInvalidAttributes = !attributes.cpoz && (!attributes.zrus || attributes.zrus === "false");
|
|
67
|
-
if (
|
|
71
|
+
if (isDPPTrip || isRegionalBusTrip || hasInvalidAttributes) {
|
|
68
72
|
return null;
|
|
69
73
|
}
|
|
70
74
|
attributes.lin = attributes.lin || "none";
|
|
@@ -229,12 +233,6 @@ class MpvMessageTransformation extends transformations_1.BaseTransformation {
|
|
|
229
233
|
};
|
|
230
234
|
this.name = vehicle_positions_1.VehiclePositions.name;
|
|
231
235
|
this.config = Di_1.IntegrationEngineContainer.resolve(CoreToken_1.CoreToken.SimpleConfig);
|
|
232
|
-
this.skipAgencyNames = this.skipAgencyNames.concat(this.config
|
|
233
|
-
.getValue("module.pid.vehicle-positions.mpvIntegration.skipAgencyNames", "ARRIVA CITY,ARRIVA CITY (Neratovice)")
|
|
234
|
-
.split(","));
|
|
235
|
-
}
|
|
236
|
-
isBlacklistedAgency(agency) {
|
|
237
|
-
return agency && this.skipAgencyNames.includes(agency);
|
|
238
236
|
}
|
|
239
237
|
/**
|
|
240
238
|
* Fix source negative bearing value due to overflow by adding 256
|
|
@@ -257,6 +255,19 @@ class MpvMessageTransformation extends transformations_1.BaseTransformation {
|
|
|
257
255
|
const aswParsedStopPostId = parseInt(stopId, 10) - aswParsedStopNodeId * fixedRightPadFactor;
|
|
258
256
|
return aswParsedStopNodeId + "/" + aswParsedStopPostId;
|
|
259
257
|
}
|
|
258
|
+
/**
|
|
259
|
+
* Returns list of vehicle reg numbers that should be excluded from MPVNet processing
|
|
260
|
+
* (already processed from another source)
|
|
261
|
+
*/
|
|
262
|
+
get regionalBusRegNumberBlacklist() {
|
|
263
|
+
const valuePath = "old.datasources.pid.vehicle-positions.regNumberWhitelist.regionalBus";
|
|
264
|
+
const blacklistDict = this.config.getValue(valuePath, {});
|
|
265
|
+
const blacklist = Object.values(blacklistDict);
|
|
266
|
+
if (blacklist.length > 0 && blacklist[0] !== "*") {
|
|
267
|
+
return blacklist;
|
|
268
|
+
}
|
|
269
|
+
return null;
|
|
270
|
+
}
|
|
260
271
|
}
|
|
261
272
|
exports.MpvMessageTransformation = MpvMessageTransformation;
|
|
262
273
|
MpvMessageTransformation.ORIGIN_TIME_FORMAT = "HH:mm:ss";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MpvMessageTransformation.js","sourceRoot":"","sources":["../../../../../../src/integration-engine/vehicle-positions/workers/vehicle-positions/transformations/MpvMessageTransformation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2FAA0D;AAG1D,wEAAqE;AACrE,qEAA0F;AAC1F,2FAA4G;AAC5G,gGAA2E;AAC3E,gDAAgE;AAChE,mEAA2C;AAC3C,8EAA2E;AAC3E,oEAAiE;AAGjE,0EAA4D;AAE5D,IAAK,oBAGJ;AAHD,WAAK,oBAAoB;IACrB,0CAAkB,CAAA;IAClB,sCAAc,CAAA;AAClB,CAAC,EAHI,oBAAoB,KAApB,oBAAoB,QAGxB;AAED,MAAa,wBAAyB,SAAQ,oCAAkB;
|
|
1
|
+
{"version":3,"file":"MpvMessageTransformation.js","sourceRoot":"","sources":["../../../../../../src/integration-engine/vehicle-positions/workers/vehicle-positions/transformations/MpvMessageTransformation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2FAA0D;AAG1D,wEAAqE;AACrE,qEAA0F;AAC1F,2FAA4G;AAC5G,gGAA2E;AAC3E,gDAAgE;AAChE,mEAA2C;AAC3C,8EAA2E;AAC3E,oEAAiE;AAGjE,0EAA4D;AAE5D,IAAK,oBAGJ;AAHD,WAAK,oBAAoB;IACrB,0CAAkB,CAAA;IAClB,sCAAc,CAAA;AAClB,CAAC,EAHI,oBAAoB,KAApB,oBAAoB,QAGxB;AAED,MAAa,wBAAyB,SAAQ,oCAAkB;IAK5D;QACI,KAAK,EAAE,CAAC;QAKZ;;WAEG;QACI,cAAS,GAAG,CAAO,IAAiD,EAAkC,EAAE;YAC3G,IAAI,KAAK,GAAG,IAAI,GAAG,EAAqC,CAAC;YACzD,IAAI,KAAK,GAAG,IAAI,GAAG,EAAuB,CAAC;YAC3C,IAAI,GAAG,GAA0B;gBAC7B,SAAS,EAAE,EAAE;gBACb,KAAK,EAAE,EAAE;gBACT,KAAK,EAAE,EAAE;aACZ,CAAC;YAEF,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;gBAAE,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC;YACxC,KAAK,MAAM,OAAO,IAAI,IAAI,EAAE;gBACxB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;gBACrD,IAAI,OAAO,EAAE;oBACT,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,Q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CAAC;IAyOD;;;;;OAKG;IACK,wBAAwB,CAAC,OAAe;QAC5C,OAAO,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,GAAG,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC;IACjD,CAAC;IAED;;;;;OAKG;IACK,eAAe,CAAC,MAAc;QAClC,MAAM,mBAAmB,GAAG,KAAK,CAAC;QAClC,MAAM,mBAAmB,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,mBAAmB,CAAC,CAAC;QACnF,MAAM,mBAAmB,GAAG,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,mBAAmB,GAAG,mBAAmB,CAAC;QAC7F,OAAO,mBAAmB,GAAG,GAAG,GAAG,mBAAmB,CAAC;IAC3D,CAAC;IAED;;;OAGG;IACH,IAAY,6BAA6B;QACrC,MAAM,SAAS,GAAG,sEAAsE,CAAC;QACzF,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAyB,SAAS,EAAE,EAAE,CAAC,CAAC;QAClF,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;QAE/C,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;YAC9C,OAAO,SAAS,CAAC;SACpB;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;;AAvRL,4DAwRC;AArRkB,2CAAkB,GAAG,UAAU,AAAb,CAAc"}
|
|
@@ -1280,6 +1280,10 @@ Worker má na starost retenci dat tabulek Azure Table Storage
|
|
|
1280
1280
|
- `shapes`: seznam tvarů trasy (podle GTFS; nejedná se o naše předpočítané anchor pointy, které se mimo zastávky oproti GTFS shapes mohou lišit), ve formátu geojson
|
|
1281
1281
|
- `vehicle_descriptor`: informace o vozidle (dopravce, dostupnost klimatizace, USB, ...)
|
|
1282
1282
|
|
|
1283
|
+
#### _/public/vehiclepositions/{vehicleId}{gtfsTripId}_
|
|
1284
|
+
|
|
1285
|
+
- rozšíření endpointu výše `/public/vehiclepositions/{vehicleId}` o možnost dotázat se na before track (delayed) spoje podle `gtfsTripId`
|
|
1286
|
+
|
|
1283
1287
|
#### _/public/departureboards_
|
|
1284
1288
|
|
|
1285
1289
|
- načte nacacheované odjezdy z redisu
|
package/docs/openapi-output.yaml
CHANGED
|
@@ -23,10 +23,10 @@ tags:
|
|
|
23
23
|
description: General Transit Feed Specification data about the city's public transportation schedules in form of an API.
|
|
24
24
|
|
|
25
25
|
- name: 🗺 GTFS Realtime
|
|
26
|
-
description: Protobuf feeds of GTFS Realtime data. The feeds are updated every 20 seconds. Proto definitions can be found at [gtfs-realtime-OVapi.proto](https://gitlab.com/operator-ict/golemio/code/ovapi-gtfs-realtime-bindings/-/blob/master/src/gtfs-realtime-OVapi.proto).
|
|
26
|
+
description: Protobuf feeds of GTFS Realtime data. The feeds are updated every 20 seconds. Proto definitions can be found at [gtfs-realtime-OVapi.proto](https://gitlab.com/operator-ict/golemio/code/ovapi-gtfs-realtime-bindings/-/blob/master/src/gtfs-realtime-OVapi.proto). You can inspect the data in human-readable form using the [GTFS Realtime Inspector](https://gitlab.com/operator-ict/golemio/code/modules/pid/-/tree/master/toolkit/gtfs-realtime-inspector).
|
|
27
27
|
|
|
28
28
|
- name: 🛤 PID Realtime Positions
|
|
29
|
-
description:
|
|
29
|
+
description: Realtime positions of vehicles in custom GeoJSON format.
|
|
30
30
|
|
|
31
31
|
- name: 🚏 PID Departure Boards
|
|
32
32
|
description: ""
|
|
@@ -75,6 +75,12 @@ paths:
|
|
|
75
75
|
responses:
|
|
76
76
|
"200":
|
|
77
77
|
description: successful operation
|
|
78
|
+
headers:
|
|
79
|
+
Cache-Control:
|
|
80
|
+
description: Cache control directive for caching proxies
|
|
81
|
+
schema:
|
|
82
|
+
type: string
|
|
83
|
+
example: public, s-maxage=14400, stale-while-revalidate=60
|
|
78
84
|
content:
|
|
79
85
|
application/json:
|
|
80
86
|
schema:
|
|
@@ -112,6 +118,12 @@ paths:
|
|
|
112
118
|
responses:
|
|
113
119
|
"200":
|
|
114
120
|
description: successful operation
|
|
121
|
+
headers:
|
|
122
|
+
Cache-Control:
|
|
123
|
+
description: Cache control directive for caching proxies
|
|
124
|
+
schema:
|
|
125
|
+
type: string
|
|
126
|
+
example: public, s-maxage=14400, stale-while-revalidate=60
|
|
115
127
|
content:
|
|
116
128
|
application/json:
|
|
117
129
|
schema:
|
|
@@ -139,6 +151,12 @@ paths:
|
|
|
139
151
|
responses:
|
|
140
152
|
"200":
|
|
141
153
|
description: successful operation
|
|
154
|
+
headers:
|
|
155
|
+
Cache-Control:
|
|
156
|
+
description: Cache control directive for caching proxies
|
|
157
|
+
schema:
|
|
158
|
+
type: string
|
|
159
|
+
example: public, s-maxage=14400, stale-while-revalidate=60
|
|
142
160
|
content:
|
|
143
161
|
application/json:
|
|
144
162
|
schema:
|
|
@@ -188,6 +206,12 @@ paths:
|
|
|
188
206
|
responses:
|
|
189
207
|
"200":
|
|
190
208
|
description: successful operation
|
|
209
|
+
headers:
|
|
210
|
+
Cache-Control:
|
|
211
|
+
description: Cache control directive for caching proxies
|
|
212
|
+
schema:
|
|
213
|
+
type: string
|
|
214
|
+
example: public, s-maxage=14400, stale-while-revalidate=60
|
|
191
215
|
content:
|
|
192
216
|
application/json:
|
|
193
217
|
schema:
|
|
@@ -257,6 +281,12 @@ paths:
|
|
|
257
281
|
responses:
|
|
258
282
|
"200":
|
|
259
283
|
description: successful operation
|
|
284
|
+
headers:
|
|
285
|
+
Cache-Control:
|
|
286
|
+
description: Cache control directive for caching proxies
|
|
287
|
+
schema:
|
|
288
|
+
type: string
|
|
289
|
+
example: public, s-maxage=14400, stale-while-revalidate=60
|
|
260
290
|
content:
|
|
261
291
|
application/json:
|
|
262
292
|
schema:
|
|
@@ -309,6 +339,12 @@ paths:
|
|
|
309
339
|
responses:
|
|
310
340
|
"200":
|
|
311
341
|
description: successful operation
|
|
342
|
+
headers:
|
|
343
|
+
Cache-Control:
|
|
344
|
+
description: Cache control directive for caching proxies
|
|
345
|
+
schema:
|
|
346
|
+
type: string
|
|
347
|
+
example: public, s-maxage=14400, stale-while-revalidate=60
|
|
312
348
|
content:
|
|
313
349
|
application/json:
|
|
314
350
|
schema:
|
|
@@ -385,6 +421,12 @@ paths:
|
|
|
385
421
|
responses:
|
|
386
422
|
"200":
|
|
387
423
|
description: successful operation
|
|
424
|
+
headers:
|
|
425
|
+
Cache-Control:
|
|
426
|
+
description: Cache control directive for caching proxies
|
|
427
|
+
schema:
|
|
428
|
+
type: string
|
|
429
|
+
example: public, s-maxage=14400, stale-while-revalidate=60
|
|
388
430
|
content:
|
|
389
431
|
application/json:
|
|
390
432
|
schema:
|
|
@@ -423,6 +465,12 @@ paths:
|
|
|
423
465
|
responses:
|
|
424
466
|
"200":
|
|
425
467
|
description: successful operation
|
|
468
|
+
headers:
|
|
469
|
+
Cache-Control:
|
|
470
|
+
description: Cache control directive for caching proxies
|
|
471
|
+
schema:
|
|
472
|
+
type: string
|
|
473
|
+
example: public, s-maxage=14400, stale-while-revalidate=60
|
|
426
474
|
content:
|
|
427
475
|
application/json:
|
|
428
476
|
schema:
|
|
@@ -499,6 +547,12 @@ paths:
|
|
|
499
547
|
responses:
|
|
500
548
|
"200":
|
|
501
549
|
description: successful operation
|
|
550
|
+
headers:
|
|
551
|
+
Cache-Control:
|
|
552
|
+
description: Cache control directive for caching proxies
|
|
553
|
+
schema:
|
|
554
|
+
type: string
|
|
555
|
+
example: public, s-maxage=14400, stale-while-revalidate=60
|
|
502
556
|
content:
|
|
503
557
|
application/json:
|
|
504
558
|
schema:
|
|
@@ -584,6 +638,17 @@ paths:
|
|
|
584
638
|
responses:
|
|
585
639
|
"200":
|
|
586
640
|
description: successful operation
|
|
641
|
+
headers:
|
|
642
|
+
Cache-Control:
|
|
643
|
+
description: Cache control directive for caching proxies
|
|
644
|
+
schema:
|
|
645
|
+
type: string
|
|
646
|
+
example: public, s-maxage=5, stale-while-revalidate=5
|
|
647
|
+
x-last-modified:
|
|
648
|
+
description: Timestamp of the latest resource update. Use it as `?updatedSince` query parameter to obtain only newer data than this value.
|
|
649
|
+
schema:
|
|
650
|
+
type: string
|
|
651
|
+
example: "2024-06-03T09:16:16.973Z"
|
|
587
652
|
content:
|
|
588
653
|
application/json:
|
|
589
654
|
schema:
|
|
@@ -644,6 +709,12 @@ paths:
|
|
|
644
709
|
responses:
|
|
645
710
|
"200":
|
|
646
711
|
description: successful operation
|
|
712
|
+
headers:
|
|
713
|
+
Cache-Control:
|
|
714
|
+
description: Cache control directive for caching proxies
|
|
715
|
+
schema:
|
|
716
|
+
type: string
|
|
717
|
+
example: public, s-maxage=5, stale-while-revalidate=5
|
|
647
718
|
content:
|
|
648
719
|
application/json:
|
|
649
720
|
schema:
|
|
@@ -667,6 +738,12 @@ paths:
|
|
|
667
738
|
responses:
|
|
668
739
|
"200":
|
|
669
740
|
description: successful operation
|
|
741
|
+
headers:
|
|
742
|
+
Cache-Control:
|
|
743
|
+
description: Cache control directive for caching proxies
|
|
744
|
+
schema:
|
|
745
|
+
type: string
|
|
746
|
+
example: no-store, no-cache, must-revalidate
|
|
670
747
|
content:
|
|
671
748
|
application/octet-stream:
|
|
672
749
|
schema:
|
|
@@ -686,6 +763,12 @@ paths:
|
|
|
686
763
|
responses:
|
|
687
764
|
"200":
|
|
688
765
|
description: successful operation
|
|
766
|
+
headers:
|
|
767
|
+
Cache-Control:
|
|
768
|
+
description: Cache control directive for caching proxies
|
|
769
|
+
schema:
|
|
770
|
+
type: string
|
|
771
|
+
example: no-store, no-cache, must-revalidate
|
|
689
772
|
content:
|
|
690
773
|
application/octet-stream:
|
|
691
774
|
schema:
|
|
@@ -705,6 +788,12 @@ paths:
|
|
|
705
788
|
responses:
|
|
706
789
|
"200":
|
|
707
790
|
description: successful operation
|
|
791
|
+
headers:
|
|
792
|
+
Cache-Control:
|
|
793
|
+
description: Cache control directive for caching proxies
|
|
794
|
+
schema:
|
|
795
|
+
type: string
|
|
796
|
+
example: no-store, no-cache, must-revalidate
|
|
708
797
|
content:
|
|
709
798
|
application/octet-stream:
|
|
710
799
|
schema:
|
|
@@ -724,6 +813,12 @@ paths:
|
|
|
724
813
|
responses:
|
|
725
814
|
"200":
|
|
726
815
|
description: successful operation
|
|
816
|
+
headers:
|
|
817
|
+
Cache-Control:
|
|
818
|
+
description: Cache control directive for caching proxies
|
|
819
|
+
schema:
|
|
820
|
+
type: string
|
|
821
|
+
example: no-store, no-cache, must-revalidate
|
|
727
822
|
content:
|
|
728
823
|
application/octet-stream:
|
|
729
824
|
schema:
|
|
@@ -874,6 +969,12 @@ paths:
|
|
|
874
969
|
responses:
|
|
875
970
|
"200":
|
|
876
971
|
description: Can return empty data in departures property (empty array []) if no departures were found
|
|
972
|
+
headers:
|
|
973
|
+
Cache-Control:
|
|
974
|
+
description: Cache control directive for caching proxies
|
|
975
|
+
schema:
|
|
976
|
+
type: string
|
|
977
|
+
example: public, s-maxage=5, stale-while-revalidate=5
|
|
877
978
|
content:
|
|
878
979
|
application/json:
|
|
879
980
|
schema:
|
|
@@ -892,6 +993,12 @@ paths:
|
|
|
892
993
|
responses:
|
|
893
994
|
"200":
|
|
894
995
|
description: List of all active infotexts
|
|
996
|
+
headers:
|
|
997
|
+
Cache-Control:
|
|
998
|
+
description: Cache control directive for caching proxies
|
|
999
|
+
schema:
|
|
1000
|
+
type: string
|
|
1001
|
+
example: public, s-maxage=25, stale-while-revalidate=10
|
|
895
1002
|
content:
|
|
896
1003
|
application/json:
|
|
897
1004
|
schema:
|
|
@@ -984,6 +1091,12 @@ paths:
|
|
|
984
1091
|
responses:
|
|
985
1092
|
200:
|
|
986
1093
|
description: OK
|
|
1094
|
+
headers:
|
|
1095
|
+
Cache-Control:
|
|
1096
|
+
description: Cache control directive for caching proxies
|
|
1097
|
+
schema:
|
|
1098
|
+
type: string
|
|
1099
|
+
example: public, s-maxage=14400, stale-while-revalidate=60
|
|
987
1100
|
content:
|
|
988
1101
|
application/json; charset=utf-8:
|
|
989
1102
|
schema:
|
|
@@ -1037,6 +1150,12 @@ paths:
|
|
|
1037
1150
|
responses:
|
|
1038
1151
|
200:
|
|
1039
1152
|
description: OK
|
|
1153
|
+
headers:
|
|
1154
|
+
Cache-Control:
|
|
1155
|
+
description: Cache control directive for caching proxies
|
|
1156
|
+
schema:
|
|
1157
|
+
type: string
|
|
1158
|
+
example: public, s-maxage=5, stale-while-revalidate=5
|
|
1040
1159
|
content:
|
|
1041
1160
|
application/json; charset=utf-8:
|
|
1042
1161
|
schema:
|
|
@@ -1086,6 +1205,78 @@ paths:
|
|
|
1086
1205
|
responses:
|
|
1087
1206
|
200:
|
|
1088
1207
|
description: OK
|
|
1208
|
+
headers:
|
|
1209
|
+
Cache-Control:
|
|
1210
|
+
description: Cache control directive for caching proxies
|
|
1211
|
+
schema:
|
|
1212
|
+
type: string
|
|
1213
|
+
example: public, s-maxage=5, stale-while-revalidate=5
|
|
1214
|
+
content:
|
|
1215
|
+
application/json; charset=utf-8:
|
|
1216
|
+
schema:
|
|
1217
|
+
allOf:
|
|
1218
|
+
- $ref: "#/components/schemas/ScopeInfo"
|
|
1219
|
+
- $ref: "#/components/schemas/ScopeStopTimes"
|
|
1220
|
+
- $ref: "#/components/schemas/ScopeShapes"
|
|
1221
|
+
- $ref: "#/components/schemas/ScopeVehicleDescriptor"
|
|
1222
|
+
|
|
1223
|
+
401:
|
|
1224
|
+
$ref: "#/components/responses/UnauthorizedError"
|
|
1225
|
+
404:
|
|
1226
|
+
description: Not found
|
|
1227
|
+
|
|
1228
|
+
/public/vehiclepositions/{vehicleId}{gtfsTripId}:
|
|
1229
|
+
get:
|
|
1230
|
+
tags:
|
|
1231
|
+
- 🕐 Public Vehicle Positions (experimental)
|
|
1232
|
+
summary: GET Vehicle RT data (additional lookup)
|
|
1233
|
+
description: |
|
|
1234
|
+
Same as `/public/vehiclepositions/{vehicleId}` but with additional lookup by GTFS trip ID. This may be useful when vehicle is serving the previous trip and you want to get info about the next trip.
|
|
1235
|
+
Combination of `vehicleId` and `gtfsTripId` is needed because multiple vehicles can serve the same trip, and we want to select the correct one.
|
|
1236
|
+
`gtfsTripId` is specified as a path matrix parameter.
|
|
1237
|
+
<br><br>Example: `/public/vehiclepositions/service-3-1001;gtfsTripId=115_107_180501`
|
|
1238
|
+
parameters:
|
|
1239
|
+
- name: vehicleId
|
|
1240
|
+
in: path
|
|
1241
|
+
description:
|
|
1242
|
+
Filter result by vehicle ID (same as *vehicle_id* from the `/public/vehiclepositions` EP or *id* from GTFS-RT `VehicleDescriptor`).
|
|
1243
|
+
required: true
|
|
1244
|
+
schema:
|
|
1245
|
+
type: string
|
|
1246
|
+
example: "service-3-1001"
|
|
1247
|
+
- name: gtfsTripId
|
|
1248
|
+
in: path
|
|
1249
|
+
style: matrix
|
|
1250
|
+
explode: false
|
|
1251
|
+
description:
|
|
1252
|
+
Perform additional lookup by GTFS trip ID.
|
|
1253
|
+
required: true
|
|
1254
|
+
schema:
|
|
1255
|
+
type: string
|
|
1256
|
+
example: "115_107_180501"
|
|
1257
|
+
- name: scopes
|
|
1258
|
+
in: query
|
|
1259
|
+
schema:
|
|
1260
|
+
type: array
|
|
1261
|
+
items:
|
|
1262
|
+
type: string
|
|
1263
|
+
enum:
|
|
1264
|
+
- info
|
|
1265
|
+
- stop_times
|
|
1266
|
+
- shapes
|
|
1267
|
+
- vehicle_descriptor
|
|
1268
|
+
description: "Choose which scopes to include in response."
|
|
1269
|
+
required: true
|
|
1270
|
+
example: ["info"]
|
|
1271
|
+
responses:
|
|
1272
|
+
200:
|
|
1273
|
+
description: OK
|
|
1274
|
+
headers:
|
|
1275
|
+
Cache-Control:
|
|
1276
|
+
description: Cache control directive for caching proxies
|
|
1277
|
+
schema:
|
|
1278
|
+
type: string
|
|
1279
|
+
example: public, s-maxage=5, stale-while-revalidate=5
|
|
1089
1280
|
content:
|
|
1090
1281
|
application/json; charset=utf-8:
|
|
1091
1282
|
schema:
|
|
@@ -1099,6 +1290,7 @@ paths:
|
|
|
1099
1290
|
$ref: "#/components/responses/UnauthorizedError"
|
|
1100
1291
|
404:
|
|
1101
1292
|
description: Not found
|
|
1293
|
+
|
|
1102
1294
|
/public/departureboards:
|
|
1103
1295
|
get:
|
|
1104
1296
|
tags:
|
|
@@ -1142,6 +1334,12 @@ paths:
|
|
|
1142
1334
|
responses:
|
|
1143
1335
|
200:
|
|
1144
1336
|
description: OK
|
|
1337
|
+
headers:
|
|
1338
|
+
Cache-Control:
|
|
1339
|
+
description: Cache control directive for caching proxies
|
|
1340
|
+
schema:
|
|
1341
|
+
type: string
|
|
1342
|
+
example: public, s-maxage=5, stale-while-revalidate=5
|
|
1145
1343
|
content:
|
|
1146
1344
|
application/json:
|
|
1147
1345
|
schema:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@golemio/pid",
|
|
3
|
-
"version": "2.13.6
|
|
3
|
+
"version": "2.13.6",
|
|
4
4
|
"description": "Golemio PID Module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@commitlint/cli": "^11.0.0",
|
|
38
38
|
"@commitlint/config-conventional": "^11.0.0",
|
|
39
39
|
"@golemio/cli": "1.5.0",
|
|
40
|
-
"@golemio/core": "1.10.
|
|
40
|
+
"@golemio/core": "1.10.3",
|
|
41
41
|
"@golemio/db-common": "1.1.4",
|
|
42
42
|
"@golemio/eslint-config": "1.1.2",
|
|
43
43
|
"@types/amqplib": "^0.5.17",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"@golemio/core": ">=1.9.16"
|
|
77
77
|
},
|
|
78
78
|
"dependencies": {
|
|
79
|
-
"@golemio/ovapi-gtfs-realtime-bindings": "1.2.
|
|
79
|
+
"@golemio/ovapi-gtfs-realtime-bindings": "1.2.3",
|
|
80
80
|
"@turf/turf": "^6.5.0",
|
|
81
81
|
"cheap-ruler": "^3.0.2",
|
|
82
82
|
"csv-parser": "^3.0.0",
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var dbm;
|
|
4
|
-
var type;
|
|
5
|
-
var seed;
|
|
6
|
-
var fs = require('fs');
|
|
7
|
-
var path = require('path');
|
|
8
|
-
var Promise;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* We receive the dbmigrate dependency from dbmigrate initially.
|
|
12
|
-
* This enables us to not have to rely on NODE_PATH.
|
|
13
|
-
*/
|
|
14
|
-
exports.setup = function(options, seedLink) {
|
|
15
|
-
dbm = options.dbmigrate;
|
|
16
|
-
type = dbm.dataType;
|
|
17
|
-
seed = seedLink;
|
|
18
|
-
Promise = options.Promise;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
exports.up = function(db) {
|
|
22
|
-
var filePath = path.join(__dirname, 'sqls', '20240523123717-add-stop-name-and-gps-to-history-data-up.sql');
|
|
23
|
-
return new Promise( function( resolve, reject ) {
|
|
24
|
-
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
|
|
25
|
-
if (err) return reject(err);
|
|
26
|
-
console.log('received data: ' + data);
|
|
27
|
-
|
|
28
|
-
resolve(data);
|
|
29
|
-
});
|
|
30
|
-
})
|
|
31
|
-
.then(function(data) {
|
|
32
|
-
return db.runSql(data);
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
exports.down = function(db) {
|
|
37
|
-
var filePath = path.join(__dirname, 'sqls', '20240523123717-add-stop-name-and-gps-to-history-data-down.sql');
|
|
38
|
-
return new Promise( function( resolve, reject ) {
|
|
39
|
-
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
|
|
40
|
-
if (err) return reject(err);
|
|
41
|
-
console.log('received data: ' + data);
|
|
42
|
-
|
|
43
|
-
resolve(data);
|
|
44
|
-
});
|
|
45
|
-
})
|
|
46
|
-
.then(function(data) {
|
|
47
|
-
return db.runSql(data);
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
exports._meta = {
|
|
52
|
-
"version": 1
|
|
53
|
-
};
|
package/db/migrations/postgresql/sqls/20240523123717-add-stop-name-and-gps-to-history-data-down.sql
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
alter table vehiclepositions_stop_times_history
|
|
2
|
-
drop COLUMN stop_name,
|
|
3
|
-
drop COLUMN lat,
|
|
4
|
-
drop COLUMN lng;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
drop view v_vehiclepositions_past_stop_times;
|
|
8
|
-
|
|
9
|
-
CREATE VIEW v_vehiclepositions_past_stop_times
|
|
10
|
-
AS SELECT sub.trips_id AS rt_trip_id,
|
|
11
|
-
sub.last_stop_sequence AS stop_sequence,
|
|
12
|
-
sub.last_stop_id AS stop_id,
|
|
13
|
-
sub.last_stop_arrival_time AS stop_arrival,
|
|
14
|
-
sub.last_stop_departure_time AS stop_departure,
|
|
15
|
-
max(sub.delay_stop_arrival) AS stop_arr_delay,
|
|
16
|
-
min(sub.delay_stop_departure) AS stop_dep_delay
|
|
17
|
-
FROM ( SELECT rt_position.trips_id,
|
|
18
|
-
rt_position.last_stop_sequence,
|
|
19
|
-
rt_position.last_stop_id,
|
|
20
|
-
rt_position.last_stop_arrival_time,
|
|
21
|
-
rt_position.last_stop_departure_time,
|
|
22
|
-
rt_position.delay_stop_arrival,
|
|
23
|
-
rt_position.delay_stop_departure,
|
|
24
|
-
row_number() OVER seq AS rn
|
|
25
|
-
FROM vehiclepositions_positions rt_position
|
|
26
|
-
WHERE (rt_position.delay_stop_arrival IS NOT NULL OR rt_position.delay_stop_departure IS NOT NULL) AND (rt_position.state_position::text = ANY (ARRAY['on_track'::character varying::text, 'at_stop'::character varying::text, 'after_track'::character varying::text]))
|
|
27
|
-
WINDOW seq AS (PARTITION BY rt_position.trips_id, rt_position.last_stop_sequence, rt_position.state_position ORDER BY rt_position.id)) sub
|
|
28
|
-
WHERE sub.rn = 1
|
|
29
|
-
GROUP BY sub.trips_id, sub.last_stop_arrival_time, sub.last_stop_departure_time, sub.last_stop_sequence, sub.last_stop_id
|
|
30
|
-
ORDER BY sub.trips_id, sub.last_stop_sequence;
|
|
31
|
-
|
|
32
|
-
CREATE OR REPLACE PROCEDURE vehiclepositions_data_retention(inout numberOfRows int, in dataRetentionMinutes int)
|
|
33
|
-
LANGUAGE plpgsql
|
|
34
|
-
SET search_path FROM CURRENT
|
|
35
|
-
AS $procedure$
|
|
36
|
-
declare
|
|
37
|
-
idsForDelete varchar(255)[];
|
|
38
|
-
begin
|
|
39
|
-
select array_agg(t.id) from vehiclepositions_trips t
|
|
40
|
-
left join vehiclepositions_positions p on
|
|
41
|
-
p.id = t.last_position_id
|
|
42
|
-
where
|
|
43
|
-
p.valid_to < (NOW() - (dataRetentionMinutes || ' minutes')::interval)
|
|
44
|
-
or (t.gtfs_trip_id is null and p.valid_to is null and p.updated_at < NOW() - (dataRetentionMinutes || ' minutes')::interval) -- entries with valid to is null
|
|
45
|
-
into idsForDelete;
|
|
46
|
-
|
|
47
|
-
INSERT INTO vehiclepositions_trips_history
|
|
48
|
-
select * from vehiclepositions_trips where id = ANY(idsForDelete)
|
|
49
|
-
on conflict do nothing;
|
|
50
|
-
|
|
51
|
-
INSERT INTO vehiclepositions_positions_history
|
|
52
|
-
select * from vehiclepositions_positions where trips_id = ANY(idsForDelete)
|
|
53
|
-
on conflict do nothing;
|
|
54
|
-
|
|
55
|
-
insert into vehiclepositions_stop_times_history (
|
|
56
|
-
rt_trip_id,
|
|
57
|
-
gtfs_date,
|
|
58
|
-
gtfs_trip_id,
|
|
59
|
-
gtfs_direction_id,
|
|
60
|
-
gtfs_route_short_name,
|
|
61
|
-
gtfs_route_type,
|
|
62
|
-
run_number,
|
|
63
|
-
vehicle_registration_number,
|
|
64
|
-
gtfs_stop_id,
|
|
65
|
-
gtfs_stop_sequence,
|
|
66
|
-
current_stop_arrival,
|
|
67
|
-
current_stop_departure,
|
|
68
|
-
current_stop_arr_delay,
|
|
69
|
-
current_stop_dep_delay,
|
|
70
|
-
created_at,
|
|
71
|
-
updated_at,
|
|
72
|
-
origin_route_name
|
|
73
|
-
)
|
|
74
|
-
select
|
|
75
|
-
rt_trip.id,
|
|
76
|
-
rt_trip.gtfs_date,
|
|
77
|
-
rt_trip.gtfs_trip_id,
|
|
78
|
-
rt_trip.gtfs_direction_id,
|
|
79
|
-
rt_trip.gtfs_route_short_name,
|
|
80
|
-
rt_trip.gtfs_route_type,
|
|
81
|
-
rt_trip.run_number,
|
|
82
|
-
rt_trip.vehicle_registration_number,
|
|
83
|
-
stop_time.stop_id,
|
|
84
|
-
stop_time.stop_sequence,
|
|
85
|
-
stop_time.stop_arrival,
|
|
86
|
-
stop_time.stop_departure,
|
|
87
|
-
stop_time.stop_arr_delay,
|
|
88
|
-
stop_time.stop_dep_delay,
|
|
89
|
-
now(),
|
|
90
|
-
now(),
|
|
91
|
-
rt_trip.origin_route_name
|
|
92
|
-
from
|
|
93
|
-
vehiclepositions_trips rt_trip
|
|
94
|
-
join
|
|
95
|
-
v_vehiclepositions_past_stop_times stop_time on stop_time.rt_trip_id = rt_trip.id
|
|
96
|
-
where
|
|
97
|
-
rt_trip.id = ANY(idsForDelete)
|
|
98
|
-
on conflict do nothing;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
delete from vehiclepositions_positions where trips_id = ANY(idsForDelete);
|
|
102
|
-
delete from vehiclepositions_trips where id = ANY(idsForDelete);
|
|
103
|
-
delete from vehiclepositions_cis_stops where rt_trip_id = ANY(idsForDelete);
|
|
104
|
-
|
|
105
|
-
select array_length(idsForDelete,1) into numberOfRows;
|
|
106
|
-
end;
|
|
107
|
-
$procedure$;
|
package/db/migrations/postgresql/sqls/20240523123717-add-stop-name-and-gps-to-history-data-up.sql
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
alter table vehiclepositions_stop_times_history
|
|
2
|
-
add COLUMN stop_name varchar(255),
|
|
3
|
-
add COLUMN lat numeric,
|
|
4
|
-
add COLUMN lng numeric;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
CREATE OR REPLACE VIEW v_vehiclepositions_past_stop_times
|
|
8
|
-
AS SELECT sub.trips_id AS rt_trip_id,
|
|
9
|
-
sub.last_stop_sequence AS stop_sequence,
|
|
10
|
-
sub.last_stop_id AS stop_id,
|
|
11
|
-
sub.last_stop_arrival_time AS stop_arrival,
|
|
12
|
-
sub.last_stop_departure_time AS stop_departure,
|
|
13
|
-
max(sub.delay_stop_arrival) AS stop_arr_delay,
|
|
14
|
-
min(sub.delay_stop_departure) AS stop_dep_delay,
|
|
15
|
-
sub.last_stop_name as stop_name,
|
|
16
|
-
sub.lat as lat,
|
|
17
|
-
sub.lng as lng
|
|
18
|
-
FROM ( SELECT rt_position.trips_id,
|
|
19
|
-
rt_position.last_stop_sequence,
|
|
20
|
-
rt_position.last_stop_id,
|
|
21
|
-
rt_position.last_stop_arrival_time,
|
|
22
|
-
rt_position.last_stop_departure_time,
|
|
23
|
-
rt_position.delay_stop_arrival,
|
|
24
|
-
rt_position.delay_stop_departure,
|
|
25
|
-
rt_position.last_stop_name,
|
|
26
|
-
rs.stop_lat as lat,
|
|
27
|
-
rs.stop_lon as lng,
|
|
28
|
-
row_number() OVER seq AS rn
|
|
29
|
-
FROM vehiclepositions_positions rt_position
|
|
30
|
-
JOIN ropidgtfs_stops rs ON rs.stop_id = rt_position.last_stop_id
|
|
31
|
-
WHERE (rt_position.delay_stop_arrival IS NOT NULL OR rt_position.delay_stop_departure IS NOT NULL) AND (rt_position.state_position::text = ANY (ARRAY['on_track'::character varying::text, 'at_stop'::character varying::text, 'after_track'::character varying::text]))
|
|
32
|
-
WINDOW seq AS (PARTITION BY rt_position.trips_id, rt_position.last_stop_sequence, rt_position.state_position ORDER BY rt_position.id)) sub
|
|
33
|
-
WHERE sub.rn = 1
|
|
34
|
-
GROUP BY sub.trips_id, sub.last_stop_arrival_time, sub.last_stop_departure_time, sub.last_stop_sequence, sub.last_stop_id, sub.last_stop_name, sub.lat, sub.lng
|
|
35
|
-
ORDER BY sub.trips_id, sub.last_stop_sequence;
|
|
36
|
-
|
|
37
|
-
CREATE OR REPLACE PROCEDURE vehiclepositions_data_retention(inout numberOfRows int, in dataRetentionMinutes int)
|
|
38
|
-
LANGUAGE plpgsql
|
|
39
|
-
SET search_path FROM CURRENT
|
|
40
|
-
AS $procedure$
|
|
41
|
-
declare
|
|
42
|
-
idsForDelete varchar(255)[];
|
|
43
|
-
begin
|
|
44
|
-
select array_agg(t.id) from vehiclepositions_trips t
|
|
45
|
-
left join vehiclepositions_positions p on
|
|
46
|
-
p.id = t.last_position_id
|
|
47
|
-
where
|
|
48
|
-
p.valid_to < (NOW() - (dataRetentionMinutes || ' minutes')::interval)
|
|
49
|
-
or (t.gtfs_trip_id is null and p.valid_to is null and p.updated_at < NOW() - (dataRetentionMinutes || ' minutes')::interval) -- entries with valid to is null
|
|
50
|
-
into idsForDelete;
|
|
51
|
-
|
|
52
|
-
INSERT INTO vehiclepositions_trips_history
|
|
53
|
-
select * from vehiclepositions_trips where id = ANY(idsForDelete)
|
|
54
|
-
on conflict do nothing;
|
|
55
|
-
|
|
56
|
-
INSERT INTO vehiclepositions_positions_history
|
|
57
|
-
select * from vehiclepositions_positions where trips_id = ANY(idsForDelete)
|
|
58
|
-
on conflict do nothing;
|
|
59
|
-
|
|
60
|
-
insert into vehiclepositions_stop_times_history (
|
|
61
|
-
rt_trip_id,
|
|
62
|
-
gtfs_date,
|
|
63
|
-
gtfs_trip_id,
|
|
64
|
-
gtfs_direction_id,
|
|
65
|
-
gtfs_route_short_name,
|
|
66
|
-
gtfs_route_type,
|
|
67
|
-
run_number,
|
|
68
|
-
vehicle_registration_number,
|
|
69
|
-
gtfs_stop_id,
|
|
70
|
-
gtfs_stop_sequence,
|
|
71
|
-
current_stop_arrival,
|
|
72
|
-
current_stop_departure,
|
|
73
|
-
current_stop_arr_delay,
|
|
74
|
-
current_stop_dep_delay,
|
|
75
|
-
created_at,
|
|
76
|
-
updated_at,
|
|
77
|
-
origin_route_name,
|
|
78
|
-
stop_name,
|
|
79
|
-
lat,
|
|
80
|
-
lng
|
|
81
|
-
)
|
|
82
|
-
select
|
|
83
|
-
rt_trip.id,
|
|
84
|
-
rt_trip.gtfs_date,
|
|
85
|
-
rt_trip.gtfs_trip_id,
|
|
86
|
-
rt_trip.gtfs_direction_id,
|
|
87
|
-
rt_trip.gtfs_route_short_name,
|
|
88
|
-
rt_trip.gtfs_route_type,
|
|
89
|
-
rt_trip.run_number,
|
|
90
|
-
rt_trip.vehicle_registration_number,
|
|
91
|
-
stop_time.stop_id,
|
|
92
|
-
stop_time.stop_sequence,
|
|
93
|
-
stop_time.stop_arrival,
|
|
94
|
-
stop_time.stop_departure,
|
|
95
|
-
stop_time.stop_arr_delay,
|
|
96
|
-
stop_time.stop_dep_delay,
|
|
97
|
-
now(),
|
|
98
|
-
now(),
|
|
99
|
-
rt_trip.origin_route_name,
|
|
100
|
-
stop_time.stop_name,
|
|
101
|
-
stop_time.lat,
|
|
102
|
-
stop_time.lng
|
|
103
|
-
from
|
|
104
|
-
vehiclepositions_trips rt_trip
|
|
105
|
-
join
|
|
106
|
-
v_vehiclepositions_past_stop_times stop_time on stop_time.rt_trip_id = rt_trip.id
|
|
107
|
-
where
|
|
108
|
-
rt_trip.id = ANY(idsForDelete)
|
|
109
|
-
on conflict do nothing;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
delete from vehiclepositions_positions where trips_id = ANY(idsForDelete);
|
|
113
|
-
delete from vehiclepositions_trips where id = ANY(idsForDelete);
|
|
114
|
-
delete from vehiclepositions_cis_stops where rt_trip_id = ANY(idsForDelete);
|
|
115
|
-
|
|
116
|
-
select array_length(idsForDelete,1) into numberOfRows;
|
|
117
|
-
end;
|
|
118
|
-
$procedure$;
|