@golemio/pid 2.0.13-dev.385144355 → 2.0.13-dev.386043250
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.
|
@@ -16,6 +16,7 @@ exports.VehiclePositionsRunsTransformation = void 0;
|
|
|
16
16
|
const moment_timezone_1 = __importDefault(require("@golemio/core/dist/shared/moment-timezone"));
|
|
17
17
|
const transformations_1 = require("@golemio/core/dist/integration-engine/transformations");
|
|
18
18
|
const vehicle_positions_1 = require("../../schema-definitions/vehicle-positions");
|
|
19
|
+
const helpers_1 = require("@golemio/core/dist/integration-engine/helpers");
|
|
19
20
|
class VehiclePositionsRunsTransformation extends transformations_1.BaseTransformation {
|
|
20
21
|
constructor() {
|
|
21
22
|
super();
|
|
@@ -25,15 +26,17 @@ class VehiclePositionsRunsTransformation extends transformations_1.BaseTransform
|
|
|
25
26
|
this.transform = ({ data, timestamp, }) => __awaiter(this, void 0, void 0, function* () {
|
|
26
27
|
const now = moment_timezone_1.default(timestamp).tz("Europe/Prague").format();
|
|
27
28
|
const res = [];
|
|
28
|
-
if (Array.isArray(data)) {
|
|
29
|
-
|
|
29
|
+
if (!Array.isArray(data)) {
|
|
30
|
+
data = [data];
|
|
31
|
+
}
|
|
32
|
+
for (const element of data) {
|
|
33
|
+
try {
|
|
30
34
|
const elementTransformed = yield this.transformElement({ data: element, timestamp: now });
|
|
31
35
|
res.push(elementTransformed);
|
|
32
36
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
res.push(elementTransformed);
|
|
37
|
+
catch (err) {
|
|
38
|
+
helpers_1.log.warn(`VehiclePositionsRunsTransformation: run has empty string timestamps: ${JSON.stringify(element)}`);
|
|
39
|
+
}
|
|
37
40
|
}
|
|
38
41
|
return res;
|
|
39
42
|
});
|
|
@@ -41,6 +44,8 @@ class VehiclePositionsRunsTransformation extends transformations_1.BaseTransform
|
|
|
41
44
|
const attributes = element.data.$;
|
|
42
45
|
const [route_id, run_number] = attributes.turnus.split("/");
|
|
43
46
|
const uniqueKey = `${route_id}` + `_${run_number}` + `_${attributes.evc}` + `_${element.timestamp}`;
|
|
47
|
+
if (attributes.takt === "" || attributes.tjr === "" || attributes.tm === "")
|
|
48
|
+
return Promise.reject();
|
|
44
49
|
return {
|
|
45
50
|
run: {
|
|
46
51
|
id: uniqueKey,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VehiclePositionsRunsTransformation.js","sourceRoot":"","sources":["../../../src/integration-engine/vehicle-positions/VehiclePositionsRunsTransformation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gGAA+D;AAC/D,2FAA4G;AAC5G,kFAA0D;AA+
|
|
1
|
+
{"version":3,"file":"VehiclePositionsRunsTransformation.js","sourceRoot":"","sources":["../../../src/integration-engine/vehicle-positions/VehiclePositionsRunsTransformation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gGAA+D;AAC/D,2FAA4G;AAC5G,kFAA0D;AAC1D,2EAAoE;AA+DpE,MAAa,kCAAmC,SAAQ,oCAAkB;IAGtE;QACI,KAAK,EAAE,CAAC;QAIZ;;WAEG;QACI,cAAS,GAAG,CAAO,EACtB,IAAI,EACJ,SAAS,GAIZ,EAAyC,EAAE;YACxC,MAAM,GAAG,GAAG,yBAAM,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,MAAM,EAAE,CAAC;YAC3D,MAAM,GAAG,GAAiC,EAAE,CAAC;YAE7C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBACtB,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC;aACjB;YACD,KAAK,MAAM,OAAO,IAAI,IAAI,EAAE;gBACxB,IAAI;oBACA,MAAM,kBAAkB,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC;oBAC1F,GAAG,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