@golemio/energetics 1.13.1-dev.2750392900 → 1.13.1-dev.2773070597

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.
Files changed (69) hide show
  1. package/db/example/07_enapo_om_detail.sql +15 -10
  2. package/db/example/09_enapo_consumption_history.sql +196 -0
  3. package/db/migrations/postgresql/20260813090000-enapo-consumption-history.js +53 -0
  4. package/db/migrations/postgresql/sqls/20260813090000-enapo-consumption-history-down.sql +12 -0
  5. package/db/migrations/postgresql/sqls/20260813090000-enapo-consumption-history-up.sql +472 -0
  6. package/dist/integration-engine/enapo/ioc/Di.js +5 -1
  7. package/dist/integration-engine/enapo/ioc/Di.js.map +1 -1
  8. package/dist/integration-engine/enapo/ioc/EnapoWorkerContainerToken.d.ts +2 -0
  9. package/dist/integration-engine/enapo/ioc/EnapoWorkerContainerToken.js +2 -0
  10. package/dist/integration-engine/enapo/ioc/EnapoWorkerContainerToken.js.map +1 -1
  11. package/dist/integration-engine/enapo/repositories/AbstractMaterializedViewIndexRepository.d.ts +8 -0
  12. package/dist/integration-engine/enapo/repositories/AbstractMaterializedViewIndexRepository.js +25 -0
  13. package/dist/integration-engine/enapo/repositories/AbstractMaterializedViewIndexRepository.js.map +1 -0
  14. package/dist/integration-engine/enapo/repositories/DedSearchIndexRepository.d.ts +2 -3
  15. package/dist/integration-engine/enapo/repositories/DedSearchIndexRepository.js +3 -23
  16. package/dist/integration-engine/enapo/repositories/DedSearchIndexRepository.js.map +1 -1
  17. package/dist/integration-engine/enapo/repositories/EnapoConsumptionHistoryIndexRepository.d.ts +6 -0
  18. package/dist/integration-engine/enapo/repositories/EnapoConsumptionHistoryIndexRepository.js +30 -0
  19. package/dist/integration-engine/enapo/repositories/EnapoConsumptionHistoryIndexRepository.js.map +1 -0
  20. package/dist/integration-engine/enapo/repositories/interfaces/IEnapoConsumptionHistoryIndexRepository.d.ts +7 -0
  21. package/dist/integration-engine/enapo/repositories/interfaces/IEnapoConsumptionHistoryIndexRepository.js +3 -0
  22. package/dist/integration-engine/enapo/repositories/interfaces/IEnapoConsumptionHistoryIndexRepository.js.map +1 -0
  23. package/dist/integration-engine/enapo/workers/EnapoWorker.js +1 -0
  24. package/dist/integration-engine/enapo/workers/EnapoWorker.js.map +1 -1
  25. package/dist/integration-engine/enapo/workers/task/EnapoConsumptionHistoryRefreshTask.d.ts +10 -0
  26. package/dist/integration-engine/enapo/workers/task/EnapoConsumptionHistoryRefreshTask.js +47 -0
  27. package/dist/integration-engine/enapo/workers/task/EnapoConsumptionHistoryRefreshTask.js.map +1 -0
  28. package/dist/output-gateway/constants/ConsumptionHistory.d.ts +2 -0
  29. package/dist/output-gateway/constants/ConsumptionHistory.js +6 -0
  30. package/dist/output-gateway/constants/ConsumptionHistory.js.map +1 -0
  31. package/dist/output-gateway/controllers/v2/EnoBuildingsController.js +3 -3
  32. package/dist/output-gateway/controllers/v2/EnoBuildingsController.js.map +1 -1
  33. package/dist/output-gateway/helpers/ConsumptionHistoryWindow.d.ts +12 -0
  34. package/dist/output-gateway/helpers/ConsumptionHistoryWindow.js +30 -0
  35. package/dist/output-gateway/helpers/ConsumptionHistoryWindow.js.map +1 -0
  36. package/dist/output-gateway/models/EnapoOmConsumptionViewModel.d.ts +23 -0
  37. package/dist/output-gateway/models/EnapoOmConsumptionViewModel.js +48 -0
  38. package/dist/output-gateway/models/EnapoOmConsumptionViewModel.js.map +1 -0
  39. package/dist/output-gateway/models/interfaces/IEnapoOmConsumptionView.d.ts +20 -0
  40. package/dist/output-gateway/models/interfaces/IEnapoOmConsumptionView.js +3 -0
  41. package/dist/output-gateway/models/interfaces/IEnapoOmConsumptionView.js.map +1 -0
  42. package/dist/output-gateway/repositories/EnapoOmConsumptionRepository.d.ts +8 -0
  43. package/dist/output-gateway/repositories/EnapoOmConsumptionRepository.js +59 -0
  44. package/dist/output-gateway/repositories/EnapoOmConsumptionRepository.js.map +1 -0
  45. package/dist/output-gateway/repositories/EnoBuildingDetailRepository.d.ts +2 -1
  46. package/dist/output-gateway/repositories/EnoBuildingDetailRepository.js +13 -3
  47. package/dist/output-gateway/repositories/EnoBuildingDetailRepository.js.map +1 -1
  48. package/dist/output-gateway/repositories/EnoConsumptionPointsRepository.d.ts +2 -0
  49. package/dist/output-gateway/repositories/EnoConsumptionPointsRepository.js +34 -0
  50. package/dist/output-gateway/repositories/EnoConsumptionPointsRepository.js.map +1 -1
  51. package/dist/output-gateway/repositories/interfaces/IEnoBuildingDetailAggregate.d.ts +6 -1
  52. package/dist/output-gateway/repositories/interfaces/IEnoSharedPointRow.d.ts +5 -0
  53. package/dist/output-gateway/repositories/interfaces/IEnoSharedPointRow.js +3 -0
  54. package/dist/output-gateway/repositories/interfaces/IEnoSharedPointRow.js.map +1 -0
  55. package/dist/output-gateway/routers/interfaces/IEnoBuildingDetailResponse.d.ts +43 -18
  56. package/dist/output-gateway/routers/v2/V2EnoBuildingsRouter.js +2 -1
  57. package/dist/output-gateway/routers/v2/V2EnoBuildingsRouter.js.map +1 -1
  58. package/dist/output-gateway/transformations/EnoBuildingDetailTransformation.d.ts +6 -0
  59. package/dist/output-gateway/transformations/EnoBuildingDetailTransformation.js +53 -14
  60. package/dist/output-gateway/transformations/EnoBuildingDetailTransformation.js.map +1 -1
  61. package/dist/output-gateway/transformations/helpers/ConsumptionHistoryBuilder.d.ts +16 -0
  62. package/dist/output-gateway/transformations/helpers/ConsumptionHistoryBuilder.js +133 -0
  63. package/dist/output-gateway/transformations/helpers/ConsumptionHistoryBuilder.js.map +1 -0
  64. package/dist/output-gateway/transformations/helpers/PorsennaCoverage.d.ts +5 -0
  65. package/dist/output-gateway/transformations/helpers/PorsennaCoverage.js +40 -0
  66. package/dist/output-gateway/transformations/helpers/PorsennaCoverage.js.map +1 -0
  67. package/docs/implementation_documentation.md +67 -1
  68. package/docs/openapi-output.yaml +663 -43
  69. package/package.json +1 -1
@@ -0,0 +1,6 @@
1
+ import { IDatabaseConnector } from "@golemio/core/dist/helpers/data-access/postgres/IDatabaseConnector";
2
+ import { AbstractMaterializedViewIndexRepository } from "./AbstractMaterializedViewIndexRepository";
3
+ import { IEnapoConsumptionHistoryIndexRepository } from "./interfaces/IEnapoConsumptionHistoryIndexRepository";
4
+ export declare class EnapoConsumptionHistoryIndexRepository extends AbstractMaterializedViewIndexRepository implements IEnapoConsumptionHistoryIndexRepository {
5
+ constructor(connector: IDatabaseConnector);
6
+ }
@@ -0,0 +1,30 @@
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
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.EnapoConsumptionHistoryIndexRepository = void 0;
16
+ const CoreToken_1 = require("@golemio/core/dist/helpers/ioc/CoreToken");
17
+ const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
18
+ const AbstractMaterializedViewIndexRepository_1 = require("./AbstractMaterializedViewIndexRepository");
19
+ let EnapoConsumptionHistoryIndexRepository = class EnapoConsumptionHistoryIndexRepository extends AbstractMaterializedViewIndexRepository_1.AbstractMaterializedViewIndexRepository {
20
+ constructor(connector) {
21
+ super(connector, "mv_enapo_om_consumption", "Failed to refresh the consumption history index.");
22
+ }
23
+ };
24
+ exports.EnapoConsumptionHistoryIndexRepository = EnapoConsumptionHistoryIndexRepository;
25
+ exports.EnapoConsumptionHistoryIndexRepository = EnapoConsumptionHistoryIndexRepository = __decorate([
26
+ (0, tsyringe_1.injectable)(),
27
+ __param(0, (0, tsyringe_1.inject)(CoreToken_1.CoreToken.PostgresConnector)),
28
+ __metadata("design:paramtypes", [Object])
29
+ ], EnapoConsumptionHistoryIndexRepository);
30
+ //# sourceMappingURL=EnapoConsumptionHistoryIndexRepository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EnapoConsumptionHistoryIndexRepository.js","sourceRoot":"","sources":["../../../../src/integration-engine/enapo/repositories/EnapoConsumptionHistoryIndexRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,wEAAqE;AACrE,iEAAwE;AACxE,uGAAoG;AAI7F,IAAM,sCAAsC,GAA5C,MAAM,sCACT,SAAQ,iFAAuC;IAG/C,YAAiD,SAA6B;QAC1E,KAAK,CAAC,SAAS,EAAE,yBAAyB,EAAE,kDAAkD,CAAC,CAAC;IACpG,CAAC;CACJ,CAAA;AAPY,wFAAsC;iDAAtC,sCAAsC;IADlD,IAAA,qBAAU,GAAE;IAKI,WAAA,IAAA,iBAAM,EAAC,qBAAS,CAAC,iBAAiB,CAAC,CAAA;;GAJvC,sCAAsC,CAOlD"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Rebuild contract of the consumption-history index. The refresh takes no parameters and always
3
+ * rebuilds the whole materialized view, so there is nothing to return.
4
+ */
5
+ export interface IEnapoConsumptionHistoryIndexRepository {
6
+ refresh(): Promise<void>;
7
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IEnapoConsumptionHistoryIndexRepository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IEnapoConsumptionHistoryIndexRepository.js","sourceRoot":"","sources":["../../../../../src/integration-engine/enapo/repositories/interfaces/IEnapoConsumptionHistoryIndexRepository.ts"],"names":[],"mappings":""}
@@ -24,6 +24,7 @@ class EnapoWorker extends integration_engine_1.AbstractWorker {
24
24
  this.registerTask(Di_1.EnapoContainer.resolve(EnapoWorkerContainerToken_1.EnapoWorkerContainerToken.EnapoPpasCommercialTask));
25
25
  this.registerTask(Di_1.EnapoContainer.resolve(EnapoWorkerContainerToken_1.EnapoWorkerContainerToken.PorsennaDistributionTask));
26
26
  this.registerTask(Di_1.EnapoContainer.resolve(EnapoWorkerContainerToken_1.EnapoWorkerContainerToken.DedSearchIndexRefreshTask));
27
+ this.registerTask(Di_1.EnapoContainer.resolve(EnapoWorkerContainerToken_1.EnapoWorkerContainerToken.EnapoConsumptionHistoryRefreshTask));
27
28
  }
28
29
  }
29
30
  exports.EnapoWorker = EnapoWorker;
@@ -1 +1 @@
1
- {"version":3,"file":"EnapoWorker.js","sourceRoot":"","sources":["../../../../src/integration-engine/enapo/workers/EnapoWorker.ts"],"names":[],"mappings":";;;AAAA,8EAAuE;AAEvE,4CAAiD;AACjD,kCAA2C;AAC3C,gFAA6E;AAE7E,MAAa,WAAY,SAAQ,mCAAc;IAG3C;QACI,KAAK,EAAE,CAAC;QAHF,SAAI,GAAG,6BAAiB,CAAC;QAkB5B,iBAAY,GAAG,CAAC,IAAW,EAAQ,EAAE;YACxC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;YACzB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;QAC7C,CAAC,CAAC;QAhBE,iBAAiB;QACjB,IAAI,CAAC,YAAY,CAAC,mBAAc,CAAC,OAAO,CAAQ,qDAAyB,CAAC,aAAa,CAAC,CAAC,CAAC;QAC1F,IAAI,CAAC,YAAY,CAAC,mBAAc,CAAC,OAAO,CAAQ,qDAAyB,CAAC,cAAc,CAAC,CAAC,CAAC;QAC3F,IAAI,CAAC,YAAY,CAAC,mBAAc,CAAC,OAAO,CAAQ,qDAAyB,CAAC,aAAa,CAAC,CAAC,CAAC;QAC1F,IAAI,CAAC,YAAY,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C;QAC1F,IAAI,CAAC,YAAY,CAAC,mBAAc,CAAC,OAAO,CAAQ,qDAAyB,CAAC,cAAc,CAAC,CAAC,CAAC;QAC3F,IAAI,CAAC,YAAY,CAAC,mBAAc,CAAC,OAAO,CAAQ,qDAAyB,CAAC,aAAa,CAAC,CAAC,CAAC;QAC1F,IAAI,CAAC,YAAY,CAAC,mBAAc,CAAC,OAAO,CAAQ,qDAAyB,CAAC,eAAe,CAAC,CAAC,CAAC;QAC5F,IAAI,CAAC,YAAY,CAAC,mBAAc,CAAC,OAAO,CAAQ,qDAAyB,CAAC,gBAAgB,CAAC,CAAC,CAAC;QAC7F,IAAI,CAAC,YAAY,CAAC,mBAAc,CAAC,OAAO,CAAQ,qDAAyB,CAAC,eAAe,CAAC,CAAC,CAAC;QAC5F,IAAI,CAAC,YAAY,CAAC,mBAAc,CAAC,OAAO,CAAQ,qDAAyB,CAAC,yBAAyB,CAAC,CAAC,CAAC;QACtG,IAAI,CAAC,YAAY,CAAC,mBAAc,CAAC,OAAO,CAAQ,qDAAyB,CAAC,uBAAuB,CAAC,CAAC,CAAC;QACpG,IAAI,CAAC,YAAY,CAAC,mBAAc,CAAC,OAAO,CAAQ,qDAAyB,CAAC,wBAAwB,CAAC,CAAC,CAAC;QACrG,IAAI,CAAC,YAAY,CAAC,mBAAc,CAAC,OAAO,CAAQ,qDAAyB,CAAC,yBAAyB,CAAC,CAAC,CAAC;QACtG,IAAI,CAAC,YAAY,CAAC,mBAAc,CAAC,OAAO,CAAQ,qDAAyB,CAAC,kCAAkC,CAAC,CAAC,CAAC;IACnH,CAAC;CAMJ;AAxBD,kCAwBC"}
@@ -0,0 +1,10 @@
1
+ import { IEnapoConsumptionHistoryIndexRepository } from "../../repositories/interfaces/IEnapoConsumptionHistoryIndexRepository";
2
+ import { AbstractTask } from "@golemio/core/dist/integration-engine/workers/AbstractTask";
3
+ export declare class EnapoConsumptionHistoryRefreshTask extends AbstractTask<Record<string, never>> {
4
+ private consumptionHistoryIndexRepository;
5
+ queueName: string;
6
+ queueTtl: number;
7
+ protected schema: undefined;
8
+ constructor(consumptionHistoryIndexRepository: IEnapoConsumptionHistoryIndexRepository);
9
+ execute(): Promise<void>;
10
+ }
@@ -0,0 +1,47 @@
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
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.EnapoConsumptionHistoryRefreshTask = void 0;
16
+ const constants_1 = require("../../constants");
17
+ const EnapoWorkerContainerToken_1 = require("../../ioc/EnapoWorkerContainerToken");
18
+ const AbstractTask_1 = require("@golemio/core/dist/integration-engine/workers/AbstractTask");
19
+ const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
20
+ const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
21
+ let EnapoConsumptionHistoryRefreshTask = class EnapoConsumptionHistoryRefreshTask extends AbstractTask_1.AbstractTask {
22
+ constructor(consumptionHistoryIndexRepository) {
23
+ super(constants_1.ENAPO_WORKER_NAME);
24
+ this.consumptionHistoryIndexRepository = consumptionHistoryIndexRepository;
25
+ this.queueName = "refreshConsumptionHistory";
26
+ this.queueTtl = 30 * 60 * 1000;
27
+ this.schema = undefined;
28
+ }
29
+ async execute() {
30
+ try {
31
+ await this.consumptionHistoryIndexRepository.refresh();
32
+ }
33
+ catch (err) {
34
+ if (err instanceof golemio_errors_1.AbstractGolemioError) {
35
+ throw err;
36
+ }
37
+ throw new golemio_errors_1.GeneralError("Failed to refresh the consumption history index.", this.constructor.name, err);
38
+ }
39
+ }
40
+ };
41
+ exports.EnapoConsumptionHistoryRefreshTask = EnapoConsumptionHistoryRefreshTask;
42
+ exports.EnapoConsumptionHistoryRefreshTask = EnapoConsumptionHistoryRefreshTask = __decorate([
43
+ (0, tsyringe_1.injectable)(),
44
+ __param(0, (0, tsyringe_1.inject)(EnapoWorkerContainerToken_1.EnapoWorkerContainerToken.EnapoConsumptionHistoryIndexRepository)),
45
+ __metadata("design:paramtypes", [Object])
46
+ ], EnapoConsumptionHistoryRefreshTask);
47
+ //# sourceMappingURL=EnapoConsumptionHistoryRefreshTask.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EnapoConsumptionHistoryRefreshTask.js","sourceRoot":"","sources":["../../../../../src/integration-engine/enapo/workers/task/EnapoConsumptionHistoryRefreshTask.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAAwD;AACxD,mFAAoF;AAEpF,6FAA0F;AAC1F,6EAA8F;AAC9F,iEAAwE;AAGjE,IAAM,kCAAkC,GAAxC,MAAM,kCAAmC,SAAQ,2BAAmC;IAKvF,YAEI,iCAAkF;QAElF,KAAK,CAAC,6BAAiB,CAAC,CAAC;QAFjB,sCAAiC,GAAjC,iCAAiC,CAAyC;QAN/E,cAAS,GAAG,2BAA2B,CAAC;QACxC,aAAQ,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;QACvB,WAAM,GAAG,SAAS,CAAC;IAO7B,CAAC;IAEM,KAAK,CAAC,OAAO;QAChB,IAAI,CAAC;YACD,MAAM,IAAI,CAAC,iCAAiC,CAAC,OAAO,EAAE,CAAC;QAC3D,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,IAAI,GAAG,YAAY,qCAAoB,EAAE,CAAC;gBACtC,MAAM,GAAG,CAAC;YACd,CAAC;YAED,MAAM,IAAI,6BAAY,CAAC,kDAAkD,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAC3G,CAAC;IACL,CAAC;CACJ,CAAA;AAvBY,gFAAkC;6CAAlC,kCAAkC;IAD9C,IAAA,qBAAU,GAAE;IAOJ,WAAA,IAAA,iBAAM,EAAC,qDAAyB,CAAC,sCAAsC,CAAC,CAAA;;GANpE,kCAAkC,CAuB9C"}
@@ -0,0 +1,2 @@
1
+ export declare const CONSUMPTION_HISTORY_MONTHS_DEFAULT = 36;
2
+ export declare const CONSUMPTION_HISTORY_MONTHS_MAX = 48;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CONSUMPTION_HISTORY_MONTHS_MAX = exports.CONSUMPTION_HISTORY_MONTHS_DEFAULT = void 0;
4
+ exports.CONSUMPTION_HISTORY_MONTHS_DEFAULT = 36;
5
+ exports.CONSUMPTION_HISTORY_MONTHS_MAX = 48;
6
+ //# sourceMappingURL=ConsumptionHistory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConsumptionHistory.js","sourceRoot":"","sources":["../../../src/output-gateway/constants/ConsumptionHistory.ts"],"names":[],"mappings":";;;AAAa,QAAA,kCAAkC,GAAG,EAAE,CAAC;AAExC,QAAA,8BAA8B,GAAG,EAAE,CAAC"}
@@ -13,6 +13,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.EnoBuildingsController = void 0;
16
+ const ConsumptionHistory_1 = require("../../constants/ConsumptionHistory");
16
17
  const DedSearchWeights_1 = require("../../constants/DedSearchWeights");
17
18
  const ModuleContainerToken_1 = require("../../ioc/ModuleContainerToken");
18
19
  const AccessLimitationRepository_1 = require("../../repositories/AccessLimitationRepository");
@@ -33,8 +34,6 @@ let EnoBuildingsController = class EnoBuildingsController extends AbstractContro
33
34
  this.search = async (req, res, next) => {
34
35
  try {
35
36
  const query = req.query.q.trim();
36
- // The router's .toInt() has already converted this; Number() only restates that for the
37
- // type system, which types req.query as string | ParsedQs | arrays of either.
38
37
  const limit = req.query.limit === undefined ? DedSearchWeights_1.DED_SEARCH_LIMIT_DEFAULT : Number(req.query.limit);
39
38
  const rows = await this.searchRepository.Search(query, limit, DedSearchWeights_1.DED_SEARCH_WEIGHTS_DEFAULT, DedSearchWeights_1.DED_SEARCH_EXACT_SCORE);
40
39
  const response = {
@@ -51,7 +50,8 @@ let EnoBuildingsController = class EnoBuildingsController extends AbstractContro
51
50
  this.getOne = async (req, res, next) => {
52
51
  try {
53
52
  const paramGid = Array.isArray(req.params.gid) ? req.params.gid[0] : req.params.gid;
54
- const result = await this.detailRepository.GetDetail(paramGid);
53
+ const months = req.query.months === undefined ? ConsumptionHistory_1.CONSUMPTION_HISTORY_MONTHS_DEFAULT : Number(req.query.months);
54
+ const result = await this.detailRepository.GetDetail(paramGid, months);
55
55
  if (result === null) {
56
56
  throw new golemio_errors_1.GeneralError("not_found", "EnoBuildingsController", undefined, 404);
57
57
  }
@@ -1 +1 @@
1
- {"version":3,"file":"EnoBuildingsController.js","sourceRoot":"","sources":["../../../../src/output-gateway/controllers/v2/EnoBuildingsController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uEAA8H;AAC9H,yEAAoE;AACpE,8FAAyF;AACzF,gGAA2F;AAC3F,gGAA2F;AAE3F,2GAAsG;AACtG,2GAAsG;AAEtG,6EAAwE;AACxE,iEAAwE;AACxE,6DAA0D;AAGnD,IAAM,sBAAsB,GAA5B,MAAM,sBAAuB,SAAQ,uCAAkB;IAC1D,YAC6D,0BAAsD,EACrD,gBAAqD,EACjD,cAAuD,EAC3D,gBAAqD,EAE/G,oBAA6D;QAE7D,KAAK,CAAC,0BAA0B,CAAC,CAAC;QANgC,qBAAgB,GAAhB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C,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC;gBACpF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;gBAE/D,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;oBAClB,MAAM,IAAI,6BAAY,CAAC,WAAW,EAAE,wBAAwB,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC;gBAClF,CAAC;gBAED,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC;YAC3D,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACX,IAAI,CAAC,GAAG,CAAC,CAAC;YACd,CAAC;QACL,CAAC,CAAC;IApCF,CAAC;CAqCJ,CAAA;AA/CY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,qBAAU,GAAE;IAGJ,WAAA,IAAA,iBAAM,EAAC,2CAAoB,CAAC,0BAA0B,CAAC,CAAA;IACvD,WAAA,IAAA,iBAAM,EAAC,2CAAoB,CAAC,2BAA2B,CAAC,CAAA;IACxD,WAAA,IAAA,iBAAM,EAAC,2CAAoB,CAAC,+BAA+B,CAAC,CAAA;IAC5D,WAAA,IAAA,iBAAM,EAAC,2CAAoB,CAAC,2BAA2B,CAAC,CAAA;IACxD,WAAA,IAAA,iBAAM,EAAC,2CAAoB,CAAC,+BAA+B,CAAC,CAAA;qCAJwB,uDAA0B;QAC3B,yDAA2B;QACzB,iEAA+B;QACjC,yDAA2B;QAEjF,iEAA+B;GAPxD,sBAAsB,CA+ClC"}
1
+ {"version":3,"file":"EnoBuildingsController.js","sourceRoot":"","sources":["../../../../src/output-gateway/controllers/v2/EnoBuildingsController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2EAAsF;AACtF,uEAA8H;AAC9H,yEAAoE;AACpE,8FAAyF;AACzF,gGAA2F;AAC3F,gGAA2F;A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AM,EAAC,2CAAoB,CAAC,2BAA2B,CAAC,CAAA;IACxD,WAAA,IAAA,iBAAM,EAAC,2CAAoB,CAAC,+BAA+B,CAAC,CAAA;qCAJwB,uDAA0B;QAC3B,yDAA2B;QACzB,iEAA+B;QACjC,yDAA2B;QAEjF,iEAA+B;GAPxD,sBAAsB,CA+ClC"}
@@ -0,0 +1,12 @@
1
+ import { DateTime } from "@golemio/core/dist/shared/luxon";
2
+ export interface IConsumptionHistoryWindow {
3
+ months: number;
4
+ periodFrom: string;
5
+ periodTo: string;
6
+ monthFrom: string;
7
+ monthSpine: string[];
8
+ yearSpine: string[];
9
+ }
10
+ export declare class ConsumptionHistoryWindow {
11
+ static build(months: number, now?: DateTime): IConsumptionHistoryWindow;
12
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConsumptionHistoryWindow = void 0;
4
+ const luxon_1 = require("@golemio/core/dist/shared/luxon");
5
+ const PERIOD_ZONE = "Europe/Prague";
6
+ class ConsumptionHistoryWindow {
7
+ static build(months, now = luxon_1.DateTime.now()) {
8
+ const lastComplete = now.setZone(PERIOD_ZONE).startOf("month").minus({ months: 1 });
9
+ const first = lastComplete.minus({ months: months - 1 });
10
+ const monthSpine = [];
11
+ for (let offset = 0; offset < months; offset++) {
12
+ monthSpine.push(first.plus({ months: offset }).toFormat("yyyy-MM"));
13
+ }
14
+ const firstYear = first.year;
15
+ const yearSpine = [];
16
+ for (let year = firstYear; year <= lastComplete.year; year++) {
17
+ yearSpine.push(String(year));
18
+ }
19
+ return {
20
+ months,
21
+ periodFrom: first.toFormat("yyyy-MM"),
22
+ periodTo: lastComplete.toFormat("yyyy-MM"),
23
+ monthFrom: first.toFormat("yyyy-MM-dd"),
24
+ monthSpine,
25
+ yearSpine,
26
+ };
27
+ }
28
+ }
29
+ exports.ConsumptionHistoryWindow = ConsumptionHistoryWindow;
30
+ //# sourceMappingURL=ConsumptionHistoryWindow.js.map
@@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AAQ,CAAC,YAAY,CAAC;YACvC,UAAU;YACV,SAAS;SACZ,CAAC;IACN,CAAC;CACJ;AAzBD,4DAyBC"}
@@ -0,0 +1,23 @@
1
+ import { EnapoConsumptionPeriodType, EnapoConsumptionSource, IEnapoOmConsumptionView } from "./interfaces/IEnapoOmConsumptionView";
2
+ import { EnapoCommodity } from "../../schema-definitions/models/enapo/interfaces/IEnapoGidMapping";
3
+ import { Model, ModelAttributes } from "@golemio/core/dist/shared/sequelize";
4
+ export declare class EnapoOmConsumptionViewModel extends Model<IEnapoOmConsumptionView> implements IEnapoOmConsumptionView {
5
+ static tableName: string;
6
+ static modelName: string;
7
+ gid: string;
8
+ place_id: string;
9
+ id_type: "ean" | "eic" | "om";
10
+ commodity: EnapoCommodity;
11
+ source: EnapoConsumptionSource;
12
+ period_type: EnapoConsumptionPeriodType;
13
+ period_start: string;
14
+ value: number;
15
+ unit: string;
16
+ value_kwh: number | null;
17
+ internal_source_var: string | null;
18
+ invoice_ids: string[];
19
+ coverage_count: number;
20
+ expected_count: number;
21
+ is_estimated: boolean;
22
+ static attributeModel: ModelAttributes<EnapoOmConsumptionViewModel, IEnapoOmConsumptionView>;
23
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EnapoOmConsumptionViewModel = void 0;
4
+ const sequelize_1 = require("@golemio/core/dist/shared/sequelize");
5
+ class EnapoOmConsumptionViewModel extends sequelize_1.Model {
6
+ }
7
+ exports.EnapoOmConsumptionViewModel = EnapoOmConsumptionViewModel;
8
+ EnapoOmConsumptionViewModel.tableName = "mv_enapo_om_consumption";
9
+ EnapoOmConsumptionViewModel.modelName = "EnapoOmConsumptionViewModelData";
10
+ EnapoOmConsumptionViewModel.attributeModel = {
11
+ gid: {
12
+ primaryKey: true,
13
+ type: sequelize_1.DataTypes.TEXT,
14
+ },
15
+ place_id: {
16
+ primaryKey: true,
17
+ type: sequelize_1.DataTypes.STRING(50),
18
+ },
19
+ commodity: {
20
+ primaryKey: true,
21
+ type: sequelize_1.DataTypes.STRING(20),
22
+ },
23
+ source: {
24
+ primaryKey: true,
25
+ type: sequelize_1.DataTypes.STRING(50),
26
+ },
27
+ unit: {
28
+ primaryKey: true,
29
+ type: sequelize_1.DataTypes.STRING(10),
30
+ },
31
+ period_type: {
32
+ primaryKey: true,
33
+ type: sequelize_1.DataTypes.STRING(10),
34
+ },
35
+ period_start: {
36
+ primaryKey: true,
37
+ type: sequelize_1.DataTypes.DATEONLY,
38
+ },
39
+ id_type: sequelize_1.DataTypes.STRING(10),
40
+ value: sequelize_1.DataTypes.DECIMAL(30, 6),
41
+ value_kwh: sequelize_1.DataTypes.DECIMAL(30, 6),
42
+ internal_source_var: sequelize_1.DataTypes.STRING(50),
43
+ invoice_ids: sequelize_1.DataTypes.ARRAY(sequelize_1.DataTypes.TEXT),
44
+ coverage_count: sequelize_1.DataTypes.INTEGER,
45
+ expected_count: sequelize_1.DataTypes.INTEGER,
46
+ is_estimated: sequelize_1.DataTypes.BOOLEAN,
47
+ };
48
+ //# sourceMappingURL=EnapoOmConsumptionViewModel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EnapoOmConsumptionViewModel.js","sourceRoot":"","sources":["../../../src/output-gateway/models/EnapoOmConsumptionViewModel.ts"],"names":[],"mappings":";;;AAMA,mEAAwF;AAExF,MAAa,2BAA4B,SAAQ,iBAA8B;;AAA/E,kEA0DC;AAzDiB,qCAAS,GAAG,yBAAyB,CAAC;AACtC,qCAAS,GAAG,iCAAiC,CAAC;AAkB9C,0CAAc,GAA0E;IAClG,GAAG,EAAE;QACD,UAAU,EAAE,IAAI;QAChB,IAAI,EAAE,qBAAS,CAAC,IAAI;KACvB;IACD,QAAQ,EAAE;QACN,UAAU,EAAE,IAAI;QAChB,IAAI,EAAE,qBAAS,CAAC,MAAM,CAAC,EAAE,CAAC;KAC7B;IACD,SAAS,EAAE;QACP,UAAU,EAAE,IAAI;QAChB,IAAI,EAAE,qBAAS,CAAC,MAAM,CAAC,EAAE,CAAC;KAC7B;IACD,MAAM,EAAE;QACJ,UAAU,EAAE,IAAI;QAChB,IAAI,EAAE,qBAAS,CAAC,MAAM,CAAC,EAAE,CAAC;KAC7B;IACD,IAAI,EAAE;QACF,UAAU,EAAE,IAAI;QAChB,IAAI,EAAE,qBAAS,CAAC,MAAM,CAAC,EAAE,CAAC;KAC7B;IACD,WAAW,EAAE;QACT,UAAU,EAAE,IAAI;QAChB,IAAI,EAAE,qBAAS,CAAC,MAAM,CAAC,EAAE,CAAC;KAC7B;IACD,YAAY,EAAE;QACV,UAAU,EAAE,IAAI;QAChB,IAAI,EAAE,qBAAS,CAAC,QAAQ;KAC3B;IACD,OAAO,EAAE,qBAAS,CAAC,MAAM,CAAC,EAAE,CAAC;IAC7B,KAAK,EAAE,qBAAS,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;IAC/B,SAAS,EAAE,qBAAS,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;IACnC,mBAAmB,EAAE,qBAAS,CAAC,MAAM,CAAC,EAAE,CAAC;IACzC,WAAW,EAAE,qBAAS,CAAC,KAAK,CAAC,qBAAS,CAAC,IAAI,CAAC;IAC5C,cAAc,EAAE,qBAAS,CAAC,OAAO;IACjC,cAAc,EAAE,qBAAS,CAAC,OAAO;IACjC,YAAY,EAAE,qBAAS,CAAC,OAAO;CAClC,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { EnapoCommodity } from "../../../schema-definitions/models/enapo/interfaces/IEnapoGidMapping";
2
+ export type EnapoConsumptionPeriodType = "monthly" | "yearly";
3
+ export type EnapoConsumptionSource = "predi_input" | "ppas_ave_api" | "ppas_distribution_invoice" | "ppas_commercial_invoice" | "porsenna";
4
+ export interface IEnapoOmConsumptionView {
5
+ gid: string;
6
+ place_id: string;
7
+ id_type: "ean" | "eic" | "om";
8
+ commodity: EnapoCommodity;
9
+ source: EnapoConsumptionSource;
10
+ period_type: EnapoConsumptionPeriodType;
11
+ period_start: string;
12
+ value: number;
13
+ unit: string;
14
+ value_kwh: number | null;
15
+ internal_source_var: string | null;
16
+ invoice_ids: string[];
17
+ coverage_count: number;
18
+ expected_count: number;
19
+ is_estimated: boolean;
20
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IEnapoOmConsumptionView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IEnapoOmConsumptionView.js","sourceRoot":"","sources":["../../../../src/output-gateway/models/interfaces/IEnapoOmConsumptionView.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ import { IEnapoOmConsumptionView } from "../models/interfaces/IEnapoOmConsumptionView";
2
+ import { AbstractNumericParsingRepository } from "./AbstractNumericParsingRepository";
3
+ export declare class EnapoOmConsumptionRepository extends AbstractNumericParsingRepository {
4
+ constructor();
5
+ GetByGid(gid: string, monthFrom: string): Promise<IEnapoOmConsumptionView[]>;
6
+ GetAll(): never;
7
+ GetOne(): never;
8
+ }
@@ -0,0 +1,59 @@
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.EnapoOmConsumptionRepository = void 0;
13
+ const EnapoOmConsumptionViewModel_1 = require("../models/EnapoOmConsumptionViewModel");
14
+ const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
15
+ const sequelize_1 = require("@golemio/core/dist/shared/sequelize");
16
+ const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
17
+ const AbstractNumericParsingRepository_1 = require("./AbstractNumericParsingRepository");
18
+ let EnapoOmConsumptionRepository = class EnapoOmConsumptionRepository extends AbstractNumericParsingRepository_1.AbstractNumericParsingRepository {
19
+ constructor() {
20
+ super(EnapoOmConsumptionViewModel_1.EnapoOmConsumptionViewModel.modelName, EnapoOmConsumptionViewModel_1.EnapoOmConsumptionViewModel.tableName, EnapoOmConsumptionViewModel_1.EnapoOmConsumptionViewModel.attributeModel, {
21
+ schema: "energetics",
22
+ });
23
+ }
24
+ async GetByGid(gid, monthFrom) {
25
+ try {
26
+ const rows = (await this.sequelizeModel.findAll({
27
+ where: {
28
+ gid,
29
+ [sequelize_1.Op.or]: [{ period_type: "yearly" }, { period_type: "monthly", period_start: { [sequelize_1.Op.gte]: monthFrom } }],
30
+ },
31
+ order: [
32
+ ["commodity", "ASC"],
33
+ ["source", "ASC"],
34
+ ["unit", "ASC"],
35
+ ["place_id", "ASC"],
36
+ ["period_type", "ASC"],
37
+ ["period_start", "ASC"],
38
+ ],
39
+ raw: true,
40
+ }));
41
+ return this.parseNumericColumns(rows);
42
+ }
43
+ catch (err) {
44
+ throw new golemio_errors_1.GeneralError("Database error ~ GetByGid EnapoOmConsumptionRepository", this.name, err, 500);
45
+ }
46
+ }
47
+ GetAll() {
48
+ throw new Error("Not implemented");
49
+ }
50
+ GetOne() {
51
+ throw new Error("Not implemented");
52
+ }
53
+ };
54
+ exports.EnapoOmConsumptionRepository = EnapoOmConsumptionRepository;
55
+ exports.EnapoOmConsumptionRepository = EnapoOmConsumptionRepository = __decorate([
56
+ (0, tsyringe_1.injectable)(),
57
+ __metadata("design:paramtypes", [])
58
+ ], EnapoOmConsumptionRepository);
59
+ //# sourceMappingURL=EnapoOmConsumptionRepository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EnapoOmConsumptionRepository.js","sourceRoot":"","sources":["../../../src/output-gateway/repositories/EnapoOmConsumptionRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uFAAqF;AAErF,6EAAwE;AACxE,mEAAyD;AACzD,iEAAgE;AAChE,yFAAsF;AAG/E,IAAM,4BAA4B,GAAlC,MAAM,4BAA6B,SAAQ,mEAAgC;IAC9E;QACI,KAAK,CACD,yDAA2B,CAAC,SAAS,EACrC,yDAA2B,CAAC,SAAS,EACrC,yDAA2B,CAAC,cAAc,EAC1C;YACI,MAAM,EAAE,YAAY;SACvB,CACJ,CAAC;IACN,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAC,GAAW,EAAE,SAAiB;QAChD,IAAI,CAAC;YACD,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;gBAC5C,KAAK,EAAE;oBACH,GAAG;oBACH,CAAC,cAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,EAAE,CAAC,cAAE,CAAC,GAAG,CAAC,EAAE,SAAS,EAAE,EAAE,CAAC;iBAC1G;gBACD,KAAK,EAAE;oBACH,CAAC,WAAW,EAAE,KAAK,CAAC;oBACpB,CAAC,QAAQ,EAAE,KAAK,CAAC;oBACjB,CAAC,MAAM,EAAE,KAAK,CAAC;oBACf,CAAC,UAAU,EAAE,KAAK,CAAC;oBACnB,CAAC,aAAa,EAAE,KAAK,CAAC;oBACtB,CAAC,cAAc,EAAE,KAAK,CAAC;iBAC1B;gBACD,GAAG,EAAE,IAAI;aACZ,CAAC,CAAyC,CAAC;YAE5C,OAAO,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;QAC1C,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,MAAM,IAAI,6BAAY,CAAC,wDAAwD,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QAC1G,CAAC;IACL,CAAC;IAEM,MAAM;QACT,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACvC,CAAC;IAEM,MAAM;QACT,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACvC,CAAC;CACJ,CAAA;AA3CY,oEAA4B;uCAA5B,4BAA4B;IADxC,IAAA,qBAAU,GAAE;;GACA,4BAA4B,CA2CxC"}
@@ -9,8 +9,9 @@ export declare class EnoBuildingDetailRepository extends AbstractNumericParsingR
9
9
  private commercialPricesRepository;
10
10
  private porsennaDevicesRepository;
11
11
  private porsennaConsumptionsRepository;
12
+ private consumptionHistoryRepository;
12
13
  constructor();
13
- GetDetail(gid: string): Promise<IEnoBuildingDetailAggregate | null>;
14
+ GetDetail(gid: string, months: number): Promise<IEnoBuildingDetailAggregate | null>;
14
15
  GetAll(): never;
15
16
  GetOne(): never;
16
17
  private findBuilding;
@@ -17,7 +17,9 @@ const PpasDistributionInvoiceDeviceModel_1 = require("../../schema-definitions/m
17
17
  const PpasDistributionInvoicePriceModel_1 = require("../../schema-definitions/models/enapo/ppas/PpasDistributionInvoicePriceModel");
18
18
  const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
19
19
  const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
20
+ const ConsumptionHistoryWindow_1 = require("../helpers/ConsumptionHistoryWindow");
20
21
  const AbstractNumericParsingRepository_1 = require("./AbstractNumericParsingRepository");
22
+ const EnapoOmConsumptionRepository_1 = require("./EnapoOmConsumptionRepository");
21
23
  const EnoBuildingAddressesRepository_1 = require("./EnoBuildingAddressesRepository");
22
24
  const EnoConsumptionPointsRepository_1 = require("./EnoConsumptionPointsRepository");
23
25
  const EnoPorsennaDevicesRepository_1 = require("./EnoPorsennaDevicesRepository");
@@ -36,13 +38,16 @@ let EnoBuildingDetailRepository = class EnoBuildingDetailRepository extends Abst
36
38
  this.commercialPricesRepository = new PpasInvoiceChildRepository_1.PpasInvoiceChildRepository("EnoPpasCommercialInvoicePriceModelData", PpasCommercialInvoicePriceModel_1.PpasCommercialInvoicePriceModel.TABLE_NAME, PpasCommercialInvoicePriceModel_1.PpasCommercialInvoicePriceModel.attributeModel);
37
39
  this.porsennaDevicesRepository = new EnoPorsennaDevicesRepository_1.EnoPorsennaDevicesRepository();
38
40
  this.porsennaConsumptionsRepository = new PorsennaConsumptionsRepository_1.PorsennaConsumptionsRepository();
41
+ this.consumptionHistoryRepository = new EnapoOmConsumptionRepository_1.EnapoOmConsumptionRepository();
39
42
  }
40
- async GetDetail(gid) {
41
- const [building, addresses, points, porsennaDevices] = await Promise.all([
43
+ async GetDetail(gid, months) {
44
+ const historyWindow = ConsumptionHistoryWindow_1.ConsumptionHistoryWindow.build(months);
45
+ const [building, addresses, points, porsennaDevices, consumptionHistory] = await Promise.all([
42
46
  this.findBuilding(gid),
43
47
  this.addressesRepository.GetByGid(gid),
44
48
  this.consumptionPointsRepository.GetByGid(gid),
45
49
  this.porsennaDevicesRepository.GetByGid(gid),
50
+ this.consumptionHistoryRepository.GetByGid(gid, historyWindow.monthFrom),
46
51
  ]);
47
52
  if (building === null && addresses.length === 0 && points.length === 0 && porsennaDevices.length === 0) {
48
53
  return null;
@@ -50,24 +55,29 @@ let EnoBuildingDetailRepository = class EnoBuildingDetailRepository extends Abst
50
55
  const distributionInvoiceIds = this.collectIds(points.map((point) => point.di_id));
51
56
  const commercialInvoiceIds = this.collectIds(points.map((point) => point.ci_id));
52
57
  const porsennaDeviceIds = this.collectIds(porsennaDevices.map((device) => device.device_id));
53
- const [distributionDevices, distributionPrices, commercialDevices, commercialPrices, porsennaConsumption] = await Promise.all([
58
+ const placeIds = this.collectIds(points.map((point) => point.place_id));
59
+ const [distributionDevices, distributionPrices, commercialDevices, commercialPrices, porsennaConsumption, sharedPoints] = await Promise.all([
54
60
  this.distributionDevicesRepository.GetByInvoiceIds(distributionInvoiceIds),
55
61
  this.distributionPricesRepository.GetByInvoiceIds(distributionInvoiceIds),
56
62
  this.commercialDevicesRepository.GetByInvoiceIds(commercialInvoiceIds),
57
63
  this.commercialPricesRepository.GetByInvoiceIds(commercialInvoiceIds),
58
64
  this.porsennaConsumptionsRepository.GetByDeviceIds(porsennaDeviceIds),
65
+ this.consumptionPointsRepository.GetSharedGids(gid, placeIds),
59
66
  ]);
60
67
  return {
61
68
  gid,
62
69
  building,
63
70
  addresses,
64
71
  points,
72
+ sharedPoints,
65
73
  distributionDevices,
66
74
  distributionPrices,
67
75
  commercialDevices,
68
76
  commercialPrices,
69
77
  porsennaDevices,
70
78
  porsennaConsumption,
79
+ consumptionHistory,
80
+ historyWindow,
71
81
  };
72
82
  }
73
83
  GetAll() {
@@ -1 +1 @@
1
- {"version":3,"file":"EnoBuildingDetailRepository.js","sourceRoot":"","sources":["../../../src/output-gateway/repositories/EnoBuildingDetailRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qFAAmF;AAEnF,kIAA2G;AAC3G,gIAAyG;AACzG,sIAA+G;AAC/G,oIAA6G;AAK7G,6EAAwE;AACxE,iEAAgE;AAChE,yFAAsF;AACtF,qFAAkF;AAClF,qFAAkF;AAClF,iFAA8E;AAC9E,qFAAkF;AAClF,6EAA0E;AAInE,IAAM,2BAA2B,GAAjC,MAAM,2BAA4B,SAAQ,mEAAgC;IAU7E;QACI,KAAK,CACD,uDAA0B,CAAC,SAAS,EACpC,uDAA0B,CAAC,SAAS,EACpC,uDAA0B,CAAC,cAAc,EACzC;YACI,MAAM,EAAE,YAAY;SACvB,CACJ,CAAC;QACF,IAAI,CAAC,mBAAmB,GAAG,IAAI,+DAA8B,EAAE,CAAC;QAChE,IAAI,CAAC,2BAA2B,GAAG,IAAI,+DAA8B,EAAE,CAAC;QACxE,IAAI,CAAC,6BAA6B,GAAG,IAAI,uDAA0B,CAC/D,2CAA2C,EAC3C,uEAAkC,CAAC,UAAU,EAC7C,uEAAkC,CAAC,cAA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A6C,CAAC;YAEhD,OAAO,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;QACrC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,MAAM,IAAI,6BAAY,CAAC,wDAAwD,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QAC1G,CAAC;IACL,CAAC;IAEO,UAAU,CAAC,GAAyB;QACxC,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,EAAgB,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC;IACvE,CAAC;CACJ,CAAA;AA5GY,kEAA2B;sCAA3B,2BAA2B;IADvC,IAAA,qBAAU,GAAE;;GACA,2BAA2B,CA4GvC"}
1
+ {"version":3,"file":"EnoBuildingDetailRepository.js","sourceRoot":"","sources":["../../../src/output-gateway/repositories/EnoBuildingDetailRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qFAAmF;AAEnF,kIAA2G;AAC3G,gIAAyG;AACzG,sIAA+G;AAC/G,oIAA6G;AAK7G,6EAAwE;AACxE,iEAAgE;AAChE,kFAAgF;AAChF,yFAAsF;AACtF,iFAA8E;AAC9E,qFAAkF;AAClF,qFAAkF;AAClF,iFAA8E;AAC9E,qFAAkF;AAClF,6EAA0E;AAInE,IAAM,2BAA2B,GAAjC,MAAM,2BAA4B,SAAQ,mEAAgC;IAW7E;QACI,KAAK,CACD,uDAA0B,CAAC,SAAS,EACpC,uDAA0B,CAAC,SAAS,EACpC,uDAA0B,CAAC,cAAc,EACzC;YACI,MAAM,EAAE,YAAY;SACvB,CACJ,CAAC;QACF,IAAI,CAAC,mBAAmB,GAAG,IAAI,+DAA8B,EAAE,CAAC;QAChE,IAAI,CAAC,2BAA2B,GAAG,IAAI,+DAA8B,EAAE,CAAC;QACxE,IAAI,CAAC,6BAA6B,GAAG,IAAI,uDAA0B,CAC/D,2CAA2C,EAC3C,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EP,OAAO;YACH,GAAG;YACH,QAAQ;YACR,SAAS;YACT,MAAM;YACN,YAAY;YACZ,mBAAmB;YACnB,kBAAkB;YAClB,iBAAiB;YACjB,gBAAgB;YAChB,eAAe;YACf,mBAAmB;YACnB,kBAAkB;YAClB,aAAa;SAChB,CAAC;IACN,CAAC;IAEM,MAAM;QACT,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACvC,CAAC;IAEM,MAAM;QACT,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACvC,CAAC;IAEO,KAAK,CAAC,YAAY,CAAC,GAAW;QAClC,IAAI,CAAC;YACD,MAAM,GAAG,GAAG,CAAC,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;gBAC3C,KAAK,EAAE,EAAE,GAAG,EAAE;gBACd,GAAG,EAAE,IAAI;aACZ,CAAC,CAA6C,CAAC;YAEhD,OAAO,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;QACrC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,MAAM,IAAI,6BAAY,CAAC,wDAAwD,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QAC1G,CAAC;IACL,CAAC;IAEO,UAAU,CAAC,GAAyB;QACxC,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,EAAgB,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC;IACvE,CAAC;CACJ,CAAA;AAtHY,kEAA2B;sCAA3B,2BAA2B;IADvC,IAAA,qBAAU,GAAE;;GACA,2BAA2B,CAsHvC"}
@@ -1,8 +1,10 @@
1
1
  import { IEnoConsumptionPointView } from "../models/interfaces/IEnoConsumptionPointView";
2
2
  import { AbstractNumericParsingRepository } from "./AbstractNumericParsingRepository";
3
+ import { IEnoSharedPointRow } from "./interfaces/IEnoSharedPointRow";
3
4
  export declare class EnoConsumptionPointsRepository extends AbstractNumericParsingRepository {
4
5
  constructor();
5
6
  GetByGid(gid: string): Promise<IEnoConsumptionPointView[]>;
7
+ GetSharedGids(gid: string, placeIds: string[]): Promise<IEnoSharedPointRow[]>;
6
8
  GetAll(): never;
7
9
  GetOne(): never;
8
10
  }
@@ -11,9 +11,28 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.EnoConsumptionPointsRepository = void 0;
13
13
  const EnoConsumptionPointViewModel_1 = require("../models/EnoConsumptionPointViewModel");
14
+ const constants_1 = require("../../schema-definitions/constants");
14
15
  const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
16
+ const sequelize_1 = require("@golemio/core/dist/shared/sequelize");
15
17
  const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
16
18
  const AbstractNumericParsingRepository_1 = require("./AbstractNumericParsingRepository");
19
+ const SHARED_POINTS_QUERY = `
20
+ SELECT DISTINCT
21
+ m.place_id::text AS place_id,
22
+ m.gid::text AS gid,
23
+ COALESCE(b.nazev, pb.name)::text AS name
24
+ FROM ${constants_1.PG_SCHEMA}.enapo_gid_mapping m
25
+ LEFT JOIN ${constants_1.PG_SCHEMA}.v_enapo_building_detail b ON b.gid = m.gid
26
+ LEFT JOIN LATERAL (
27
+ SELECT d.building_name AS name
28
+ FROM ${constants_1.PG_SCHEMA}.v_enapo_building_porsenna_devices d
29
+ WHERE d.gid = m.gid AND d.building_name IS NOT NULL
30
+ ORDER BY d.source ASC, d.identifier ASC
31
+ LIMIT 1
32
+ ) pb ON b.nazev IS NULL
33
+ WHERE m.place_id = ANY($placeIds) AND m.gid <> $gid
34
+ ORDER BY place_id ASC, gid ASC
35
+ `;
17
36
  let EnoConsumptionPointsRepository = class EnoConsumptionPointsRepository extends AbstractNumericParsingRepository_1.AbstractNumericParsingRepository {
18
37
  constructor() {
19
38
  super(EnoConsumptionPointViewModel_1.EnoConsumptionPointViewModel.modelName, EnoConsumptionPointViewModel_1.EnoConsumptionPointViewModel.tableName, EnoConsumptionPointViewModel_1.EnoConsumptionPointViewModel.attributeModel, {
@@ -36,6 +55,21 @@ let EnoConsumptionPointsRepository = class EnoConsumptionPointsRepository extend
36
55
  throw new golemio_errors_1.GeneralError("Database error ~ GetByGid EnoConsumptionPointsRepository", this.name, err, 500);
37
56
  }
38
57
  }
58
+ async GetSharedGids(gid, placeIds) {
59
+ if (placeIds.length === 0) {
60
+ return [];
61
+ }
62
+ try {
63
+ return await this.sequelizeModel.sequelize.query(SHARED_POINTS_QUERY, {
64
+ bind: { gid, placeIds },
65
+ raw: true,
66
+ type: sequelize_1.QueryTypes.SELECT,
67
+ });
68
+ }
69
+ catch (err) {
70
+ throw new golemio_errors_1.GeneralError("Database error ~ GetSharedGids EnoConsumptionPointsRepository", this.name, err, 500);
71
+ }
72
+ }
39
73
  GetAll() {
40
74
  throw new Error("Not implemented");
41
75
  }
@@ -1 +1 @@
1
- {"version":3,"file":"EnoConsumptionPointsRepository.js","sourceRoot":"","sources":["../../../src/output-gateway/repositories/EnoConsumptionPointsRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yFAAuF;AAEvF,6EAAwE;AACxE,iEAAgE;AAChE,yFAAsF;AAG/E,IAAM,8BAA8B,GAApC,MAAM,8BAA+B,SAAQ,mEAAgC;IAChF;QACI,KAAK,CACD,2DAA4B,CAAC,SAAS,EACtC,2DAA4B,CAAC,SAAS,EACtC,2DAA4B,CAAC,cAAc,EAC3C;YACI,MAAM,EAAE,YAAY;SACvB,CACJ,CAAC;IACN,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAC,GAAW;QAC7B,IAAI,CAAC;YACD,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;gBAC5C,KAAK,EAAE,EAAE,GAAG,EAAE;gBACd,KAAK,EAAE;oBACH,CAAC,WAAW,EAAE,KAAK,CAAC;oBACpB,CAAC,UAAU,EAAE,KAAK,CAAC;iBACtB;gBACD,GAAG,EAAE,IAAI;aACZ,CAAC,CAA0C,CAAC;YAE7C,OAAO,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;QAC1C,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,MAAM,IAAI,6BAAY,CAAC,0DAA0D,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QAC5G,CAAC;IACL,CAAC;IAEM,MAAM;QACT,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACvC,CAAC;IAEM,MAAM;QACT,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACvC,CAAC;CACJ,CAAA;AApCY,wEAA8B;yCAA9B,8BAA8B;IAD1C,IAAA,qBAAU,GAAE;;GACA,8BAA8B,CAoC1C"}
1
+ {"version":3,"file":"EnoConsumptionPointsRepository.js","sourceRoot":"","sources":["../../../src/output-gateway/repositories/EnoConsumptionPointsRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yFAAuF;AAEvF,kEAA2C;AAC3C,6EAAwE;AACxE,mEAAiE;AACjE,iEAAgE;AAChE,yFAAsF;AAGtF,MAAM,mBAAmB,GAAG;;;;;OAKrB,qBAAS;YACJ,qBAAS;;;WAGV,qBAAS;;;;;;;CAOnB,CAAC;AAGK,IAAM,8BAA8B,GAApC,MAAM,8BAA+B,SAAQ,mEAAgC;IAChF;QACI,KAAK,CACD,2DAA4B,CAAC,SAAS,EACtC,2DAA4B,CAAC,SAAS,EACtC,2DAA4B,CAAC,cAAc,EAC3C;YACI,MAAM,EAAE,YAAY;SACvB,CACJ,CAAC;IACN,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAC,GAAW;QAC7B,IAAI,CAAC;YACD,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;gBAC5C,KAAK,EAAE,EAAE,GAAG,EAAE;gBACd,KAAK,EAAE;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