@golemio/energetics 1.0.14-dev.740182146 → 1.0.14-dev.741957153
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/workers/oict-energetika/interfaces/IFetchConsumptionInput.d.ts +4 -0
- package/dist/integration-engine/workers/oict-energetika/interfaces/IFetchConsumptionInput.js +3 -0
- package/dist/integration-engine/workers/oict-energetika/interfaces/IFetchConsumptionInput.js.map +1 -0
- package/dist/integration-engine/workers/oict-energetika/schema/FetchConsumptionSchema.d.ts +5 -0
- package/dist/integration-engine/workers/oict-energetika/schema/FetchConsumptionSchema.js +25 -0
- package/dist/integration-engine/workers/oict-energetika/schema/FetchConsumptionSchema.js.map +1 -0
- package/dist/integration-engine/workers/oict-energetika/tasks/FetchConsumptionTask.d.ts +5 -5
- package/dist/integration-engine/workers/oict-energetika/tasks/FetchConsumptionTask.js +10 -10
- package/dist/integration-engine/workers/oict-energetika/tasks/FetchConsumptionTask.js.map +1 -1
- package/dist/integration-engine/workers/oict-energetika/tasks/FetchDataTask.d.ts +1 -0
- package/dist/integration-engine/workers/oict-energetika/tasks/FetchDataTask.js +17 -1
- package/dist/integration-engine/workers/oict-energetika/tasks/FetchDataTask.js.map +1 -1
- package/package.json +1 -1
package/dist/integration-engine/workers/oict-energetika/interfaces/IFetchConsumptionInput.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IFetchConsumptionInput.js","sourceRoot":"","sources":["../../../../../src/integration-engine/workers/oict-energetika/interfaces/IFetchConsumptionInput.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.FetchConsumptionValidationSchema = void 0;
|
|
13
|
+
const class_validator_1 = require("@golemio/core/dist/shared/class-validator");
|
|
14
|
+
class FetchConsumptionValidationSchema {
|
|
15
|
+
}
|
|
16
|
+
__decorate([
|
|
17
|
+
(0, class_validator_1.IsISO8601)({ strict: true }),
|
|
18
|
+
__metadata("design:type", String)
|
|
19
|
+
], FetchConsumptionValidationSchema.prototype, "dateFrom", void 0);
|
|
20
|
+
__decorate([
|
|
21
|
+
(0, class_validator_1.IsISO8601)({ strict: true }),
|
|
22
|
+
__metadata("design:type", String)
|
|
23
|
+
], FetchConsumptionValidationSchema.prototype, "dateTo", void 0);
|
|
24
|
+
exports.FetchConsumptionValidationSchema = FetchConsumptionValidationSchema;
|
|
25
|
+
//# sourceMappingURL=FetchConsumptionSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FetchConsumptionSchema.js","sourceRoot":"","sources":["../../../../../src/integration-engine/workers/oict-energetika/schema/FetchConsumptionSchema.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+EAAsE;AAGtE,MAAa,gCAAgC;CAM5C;AAJG;IADC,IAAA,2BAAS,EAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;;kEACV;AAGlB;IADC,IAAA,2BAAS,EAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;;gEACZ;AALpB,4EAMC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { AbstractTask } from "@golemio/core/dist/integration-engine/workers";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export declare class FetchConsumptionTask extends AbstractTask<
|
|
2
|
+
import { IFetchConsumptionInput } from "../interfaces/IFetchConsumptionInput";
|
|
3
|
+
import { FetchConsumptionValidationSchema } from "../schema/FetchConsumptionSchema";
|
|
4
|
+
export declare class FetchConsumptionTask extends AbstractTask<IFetchConsumptionInput> {
|
|
5
5
|
readonly queueName = "fetchConsumption";
|
|
6
6
|
readonly queueTtl: number;
|
|
7
|
-
readonly schema: typeof
|
|
7
|
+
readonly schema: typeof FetchConsumptionValidationSchema;
|
|
8
8
|
private readonly consumptionRepository;
|
|
9
9
|
private readonly consumptionTransformation;
|
|
10
10
|
constructor(queuePrefix: string);
|
|
11
|
-
protected execute(
|
|
11
|
+
protected execute(dateParams: IFetchConsumptionInput): Promise<void>;
|
|
12
12
|
private getDataSources;
|
|
13
13
|
}
|
|
@@ -15,22 +15,22 @@ const workers_1 = require("@golemio/core/dist/integration-engine/workers");
|
|
|
15
15
|
const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
|
|
16
16
|
const luxon_1 = require("@golemio/core/dist/shared/luxon");
|
|
17
17
|
const ConsumptionRepository_1 = require("../data-access/ConsumptionRepository");
|
|
18
|
-
const helpers_2 = require("../datasources/helpers");
|
|
19
18
|
const OictDataSourceFactory_1 = require("../datasources/OictDataSourceFactory");
|
|
20
|
-
const
|
|
19
|
+
const helpers_2 = require("../datasources/helpers");
|
|
20
|
+
const FetchConsumptionSchema_1 = require("../schema/FetchConsumptionSchema");
|
|
21
21
|
const ConsumptionTransformation_1 = require("../transformations/ConsumptionTransformation");
|
|
22
22
|
class FetchConsumptionTask extends workers_1.AbstractTask {
|
|
23
23
|
constructor(queuePrefix) {
|
|
24
24
|
super(queuePrefix);
|
|
25
25
|
this.queueName = "fetchConsumption";
|
|
26
|
-
this.queueTtl =
|
|
27
|
-
this.schema =
|
|
26
|
+
this.queueTtl = 10 * 60 * 60 * 1000; // 10 hours
|
|
27
|
+
this.schema = FetchConsumptionSchema_1.FetchConsumptionValidationSchema;
|
|
28
28
|
this.consumptionRepository = new ConsumptionRepository_1.ConsumptionRepository();
|
|
29
29
|
this.consumptionTransformation = new ConsumptionTransformation_1.ConsumptionTransformation();
|
|
30
30
|
}
|
|
31
|
-
execute(
|
|
31
|
+
execute(dateParams) {
|
|
32
32
|
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
-
const dataSources = this.getDataSources(
|
|
33
|
+
const dataSources = this.getDataSources(dateParams);
|
|
34
34
|
for (const dataSource of dataSources) {
|
|
35
35
|
try {
|
|
36
36
|
const data = yield dataSource.getAll();
|
|
@@ -44,10 +44,10 @@ class FetchConsumptionTask extends workers_1.AbstractTask {
|
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
|
-
*getDataSources(
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
const intervals = luxon_1.Interval.fromDateTimes(dateFrom,
|
|
47
|
+
*getDataSources(dateParams) {
|
|
48
|
+
const dateFrom = luxon_1.DateTime.fromISO(dateParams.dateFrom).startOf("day");
|
|
49
|
+
const dateTo = luxon_1.DateTime.fromISO(dateParams.dateTo).startOf("day");
|
|
50
|
+
const intervals = luxon_1.Interval.fromDateTimes(dateFrom, dateTo).splitBy({ days: 5 });
|
|
51
51
|
for (const interval of intervals) {
|
|
52
52
|
const start = interval.start.startOf("day");
|
|
53
53
|
const end = interval.end.startOf("day");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FetchConsumptionTask.js","sourceRoot":"","sources":["../../../../../src/integration-engine/workers/oict-energetika/tasks/FetchConsumptionTask.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,2EAAoE;AACpE,2EAA6E;AAC7E,6EAAuE;AACvE,2DAAqE;AACrE,gFAA6E;AAC7E,oDAA0D;
|
|
1
|
+
{"version":3,"file":"FetchConsumptionTask.js","sourceRoot":"","sources":["../../../../../src/integration-engine/workers/oict-energetika/tasks/FetchConsumptionTask.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,2EAAoE;AACpE,2EAA6E;AAC7E,6EAAuE;AACvE,2DAAqE;AACrE,gFAA6E;AAC7E,gFAA6E;AAC7E,oDAA0D;AAE1D,6EAAoF;AACpF,4FAAyF;AAEzF,MAAa,oBAAqB,SAAQ,sBAAoC;IAQ1E,YAAY,WAAmB;QAC3B,KAAK,CAAC,WAAW,CAAC,CAAC;QARP,cAAS,GAAG,kBAAkB,CAAC;QAC/B,aAAQ,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,WAAW;QAC3C,WAAM,GAAG,yDAAgC,CAAC;QAOtD,IAAI,CAAC,qBAAqB,GAAG,IAAI,6CAAqB,EAAE,CAAC;QACzD,IAAI,CAAC,yBAAyB,GAAG,IAAI,qDAAyB,EAAE,CAAC;IACrE,CAAC;IAEe,OAAO,CAAC,UAAkC;;YACtD,MAAM,WAAW,GAAG,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;YAEpD,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE;gBAClC,IAAI;oBACA,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,MAAM,EAAE,CAAC;oBACvC,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;oBAC7E,MAAM,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;iBAC9D;gBAAC,OAAO,GAAG,EAAE;oBACV,aAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;oBACf,MAAM,IAAI,4BAAW,CAAC,kCAAkC,EAAE,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC;iBAC1G;aACJ;QACL,CAAC;KAAA;IAEO,CAAC,cAAc,CAAC,UAAkC;QACtD,MAAM,QAAQ,GAAG,gBAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACtE,MAAM,MAAM,GAAG,gBAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAClE,MAAM,SAAS,GAAG,gBAAQ,CAAC,aAAa,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;QAEhF,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE;YAC9B,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAC5C,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAExC,MAAM,6CAAqB,CAAC,aAAa,CAAC,0BAAgB,CAAC,WAAW,EAAE;gBACpE,QAAQ,EAAE,KAAK,CAAC,SAAS,EAAE;gBAC3B,MAAM,EAAE,GAAG,CAAC,SAAS,EAAE;aAC1B,CAAC,CAAC;YAEH,MAAM,6CAAqB,CAAC,aAAa,CAAC,0BAAgB,CAAC,iBAAiB,EAAE;gBAC1E,QAAQ,EAAE,KAAK,CAAC,SAAS,EAAE;gBAC3B,MAAM,EAAE,GAAG,CAAC,SAAS,EAAE;aAC1B,CAAC,CAAC;SACN;IACL,CAAC;CACJ;AAjDD,oDAiDC"}
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.FetchDataTask = void 0;
|
|
13
13
|
const queueprocessors_1 = require("@golemio/core/dist/integration-engine/queueprocessors");
|
|
14
14
|
const workers_1 = require("@golemio/core/dist/integration-engine/workers");
|
|
15
|
+
const luxon_1 = require("@golemio/core/dist/shared/luxon");
|
|
15
16
|
const FetchDataSchema_1 = require("../schema/FetchDataSchema");
|
|
16
17
|
class FetchDataTask extends workers_1.AbstractTask {
|
|
17
18
|
constructor(queuePrefix) {
|
|
@@ -24,9 +25,24 @@ class FetchDataTask extends workers_1.AbstractTask {
|
|
|
24
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
26
|
yield queueprocessors_1.QueueManager.sendMessageToExchange(this.queuePrefix, "fetchBuildings", {});
|
|
26
27
|
yield queueprocessors_1.QueueManager.sendMessageToExchange(this.queuePrefix, "fetchDevices", {});
|
|
27
|
-
|
|
28
|
+
for (const dateParams of this.generateDateParams(targetDays)) {
|
|
29
|
+
yield queueprocessors_1.QueueManager.sendMessageToExchange(this.queuePrefix, "fetchConsumption", dateParams);
|
|
30
|
+
}
|
|
28
31
|
});
|
|
29
32
|
}
|
|
33
|
+
*generateDateParams(targetDays) {
|
|
34
|
+
const currentDate = luxon_1.DateTime.now().startOf("day");
|
|
35
|
+
const leftBoundDate = currentDate.minus({ days: targetDays });
|
|
36
|
+
const intervals = luxon_1.Interval.fromDateTimes(leftBoundDate, currentDate).splitBy({ months: 1 });
|
|
37
|
+
for (const interval of intervals) {
|
|
38
|
+
const start = interval.start.startOf("day");
|
|
39
|
+
const end = interval.end.startOf("day");
|
|
40
|
+
yield {
|
|
41
|
+
dateFrom: start.toISODate(),
|
|
42
|
+
dateTo: end.toISODate(),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
30
46
|
}
|
|
31
47
|
exports.FetchDataTask = FetchDataTask;
|
|
32
48
|
//# sourceMappingURL=FetchDataTask.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FetchDataTask.js","sourceRoot":"","sources":["../../../../../src/integration-engine/workers/oict-energetika/tasks/FetchDataTask.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2FAAqF;AACrF,2EAA6E;
|
|
1
|
+
{"version":3,"file":"FetchDataTask.js","sourceRoot":"","sources":["../../../../../src/integration-engine/workers/oict-energ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