@golemio/energetics 1.13.0 → 1.13.1-dev.2769672204
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/db/example/07_enapo_om_detail.sql +15 -10
- package/db/example/09_enapo_consumption_history.sql +196 -0
- package/db/migrations/postgresql/20260813090000-enapo-consumption-history.js +53 -0
- package/db/migrations/postgresql/sqls/20260813090000-enapo-consumption-history-down.sql +12 -0
- package/db/migrations/postgresql/sqls/20260813090000-enapo-consumption-history-up.sql +504 -0
- package/dist/integration-engine/enapo/ioc/Di.js +5 -1
- package/dist/integration-engine/enapo/ioc/Di.js.map +1 -1
- package/dist/integration-engine/enapo/ioc/EnapoWorkerContainerToken.d.ts +2 -0
- package/dist/integration-engine/enapo/ioc/EnapoWorkerContainerToken.js +2 -0
- package/dist/integration-engine/enapo/ioc/EnapoWorkerContainerToken.js.map +1 -1
- package/dist/integration-engine/enapo/repositories/AbstractMaterializedViewIndexRepository.d.ts +8 -0
- package/dist/integration-engine/enapo/repositories/AbstractMaterializedViewIndexRepository.js +25 -0
- package/dist/integration-engine/enapo/repositories/AbstractMaterializedViewIndexRepository.js.map +1 -0
- package/dist/integration-engine/enapo/repositories/DedSearchIndexRepository.d.ts +2 -3
- package/dist/integration-engine/enapo/repositories/DedSearchIndexRepository.js +3 -23
- package/dist/integration-engine/enapo/repositories/DedSearchIndexRepository.js.map +1 -1
- package/dist/integration-engine/enapo/repositories/EnapoConsumptionHistoryIndexRepository.d.ts +6 -0
- package/dist/integration-engine/enapo/repositories/EnapoConsumptionHistoryIndexRepository.js +30 -0
- package/dist/integration-engine/enapo/repositories/EnapoConsumptionHistoryIndexRepository.js.map +1 -0
- package/dist/integration-engine/enapo/repositories/interfaces/IEnapoConsumptionHistoryIndexRepository.d.ts +7 -0
- package/dist/integration-engine/enapo/repositories/interfaces/IEnapoConsumptionHistoryIndexRepository.js +3 -0
- package/dist/integration-engine/enapo/repositories/interfaces/IEnapoConsumptionHistoryIndexRepository.js.map +1 -0
- package/dist/integration-engine/enapo/workers/EnapoWorker.js +1 -0
- package/dist/integration-engine/enapo/workers/EnapoWorker.js.map +1 -1
- package/dist/integration-engine/enapo/workers/task/EnapoConsumptionHistoryRefreshTask.d.ts +10 -0
- package/dist/integration-engine/enapo/workers/task/EnapoConsumptionHistoryRefreshTask.js +47 -0
- package/dist/integration-engine/enapo/workers/task/EnapoConsumptionHistoryRefreshTask.js.map +1 -0
- package/dist/output-gateway/constants/ConsumptionHistory.d.ts +2 -0
- package/dist/output-gateway/constants/ConsumptionHistory.js +6 -0
- package/dist/output-gateway/constants/ConsumptionHistory.js.map +1 -0
- package/dist/output-gateway/controllers/v2/EnoBuildingsController.js +3 -3
- package/dist/output-gateway/controllers/v2/EnoBuildingsController.js.map +1 -1
- package/dist/output-gateway/helpers/ConsumptionHistoryWindow.d.ts +12 -0
- package/dist/output-gateway/helpers/ConsumptionHistoryWindow.js +30 -0
- package/dist/output-gateway/helpers/ConsumptionHistoryWindow.js.map +1 -0
- package/dist/output-gateway/models/EnapoOmConsumptionViewModel.d.ts +23 -0
- package/dist/output-gateway/models/EnapoOmConsumptionViewModel.js +48 -0
- package/dist/output-gateway/models/EnapoOmConsumptionViewModel.js.map +1 -0
- package/dist/output-gateway/models/interfaces/IEnapoOmConsumptionView.d.ts +20 -0
- package/dist/output-gateway/models/interfaces/IEnapoOmConsumptionView.js +3 -0
- package/dist/output-gateway/models/interfaces/IEnapoOmConsumptionView.js.map +1 -0
- package/dist/output-gateway/repositories/EnapoOmConsumptionRepository.d.ts +8 -0
- package/dist/output-gateway/repositories/EnapoOmConsumptionRepository.js +59 -0
- package/dist/output-gateway/repositories/EnapoOmConsumptionRepository.js.map +1 -0
- package/dist/output-gateway/repositories/EnoBuildingDetailRepository.d.ts +2 -1
- package/dist/output-gateway/repositories/EnoBuildingDetailRepository.js +13 -3
- package/dist/output-gateway/repositories/EnoBuildingDetailRepository.js.map +1 -1
- package/dist/output-gateway/repositories/EnoConsumptionPointsRepository.d.ts +2 -0
- package/dist/output-gateway/repositories/EnoConsumptionPointsRepository.js +34 -0
- package/dist/output-gateway/repositories/EnoConsumptionPointsRepository.js.map +1 -1
- package/dist/output-gateway/repositories/interfaces/IEnoBuildingDetailAggregate.d.ts +6 -1
- package/dist/output-gateway/repositories/interfaces/IEnoSharedPointRow.d.ts +5 -0
- package/dist/output-gateway/repositories/interfaces/IEnoSharedPointRow.js +3 -0
- package/dist/output-gateway/repositories/interfaces/IEnoSharedPointRow.js.map +1 -0
- package/dist/output-gateway/routers/interfaces/IEnoBuildingDetailResponse.d.ts +43 -18
- package/dist/output-gateway/routers/v2/V2EnoBuildingsRouter.js +2 -1
- package/dist/output-gateway/routers/v2/V2EnoBuildingsRouter.js.map +1 -1
- package/dist/output-gateway/transformations/EnoBuildingDetailTransformation.d.ts +6 -0
- package/dist/output-gateway/transformations/EnoBuildingDetailTransformation.js +53 -14
- package/dist/output-gateway/transformations/EnoBuildingDetailTransformation.js.map +1 -1
- package/dist/output-gateway/transformations/helpers/ConsumptionHistoryBuilder.d.ts +16 -0
- package/dist/output-gateway/transformations/helpers/ConsumptionHistoryBuilder.js +133 -0
- package/dist/output-gateway/transformations/helpers/ConsumptionHistoryBuilder.js.map +1 -0
- package/dist/output-gateway/transformations/helpers/PorsennaCoverage.d.ts +5 -0
- package/dist/output-gateway/transformations/helpers/PorsennaCoverage.js +40 -0
- package/dist/output-gateway/transformations/helpers/PorsennaCoverage.js.map +1 -0
- package/docs/implementation_documentation.md +67 -1
- package/docs/openapi-output.yaml +663 -43
- package/package.json +1 -1
|
@@ -0,0 +1,504 @@
|
|
|
1
|
+
CREATE OR REPLACE FUNCTION f_enapo_safe_period(period_kind text, period_text text)
|
|
2
|
+
RETURNS date
|
|
3
|
+
LANGUAGE plpgsql
|
|
4
|
+
STABLE
|
|
5
|
+
PARALLEL SAFE
|
|
6
|
+
AS $$
|
|
7
|
+
BEGIN
|
|
8
|
+
RETURN CASE period_kind
|
|
9
|
+
WHEN 'yearly' THEN make_date(period_text::int, 1, 1)
|
|
10
|
+
WHEN 'monthly' THEN to_date(period_text, 'YYYY-MM')
|
|
11
|
+
END;
|
|
12
|
+
EXCEPTION WHEN OTHERS THEN
|
|
13
|
+
RETURN NULL;
|
|
14
|
+
END;
|
|
15
|
+
$$;
|
|
16
|
+
|
|
17
|
+
COMMENT ON FUNCTION f_enapo_safe_period(text, text) IS
|
|
18
|
+
'Converts a Porsenna consumption period ("2025" for yearly, "2025-06" for monthly) to the first day of that period, returning NULL for anything unparsable instead of raising - a single bad row must not abort the consumption-history refresh.';
|
|
19
|
+
|
|
20
|
+
CREATE INDEX IF NOT EXISTS enapo_ppas_distribution_invoice_preceding_id_idx
|
|
21
|
+
ON enapo_ppas_distribution_invoice (preceding_id);
|
|
22
|
+
CREATE INDEX IF NOT EXISTS enapo_ppas_commercial_invoice_preceding_id_idx
|
|
23
|
+
ON enapo_ppas_commercial_invoice (preceding_id);
|
|
24
|
+
|
|
25
|
+
CREATE MATERIALIZED VIEW mv_enapo_om_consumption AS
|
|
26
|
+
WITH bounds AS (
|
|
27
|
+
SELECT
|
|
28
|
+
((date_trunc('month', now() AT TIME ZONE 'Europe/Prague') - interval '48 months')
|
|
29
|
+
AT TIME ZONE 'Europe/Prague') AS month_from_tstz,
|
|
30
|
+
(date_trunc('month', now() AT TIME ZONE 'Europe/Prague') - interval '48 months') AS month_from,
|
|
31
|
+
(date_trunc('month', now() AT TIME ZONE 'Europe/Prague')
|
|
32
|
+
AT TIME ZONE 'Europe/Prague') AS month_to_tstz,
|
|
33
|
+
date_trunc('month', now() AT TIME ZONE 'Europe/Prague') AS month_to
|
|
34
|
+
),
|
|
35
|
+
|
|
36
|
+
point AS (
|
|
37
|
+
SELECT DISTINCT gid, place_id, id_type, commodity
|
|
38
|
+
FROM v_enapo_building_consumption_points
|
|
39
|
+
),
|
|
40
|
+
|
|
41
|
+
electricity_metered AS (
|
|
42
|
+
SELECT
|
|
43
|
+
em.id AS place_id,
|
|
44
|
+
date_trunc('month', em."timestamp" AT TIME ZONE 'Europe/Prague')::date AS period_start,
|
|
45
|
+
sum(em.value) FILTER (WHERE em.var = 'EActi_VT_NT_DaySum') AS total_kwh,
|
|
46
|
+
sum(em.value) FILTER (WHERE em.var = 'EActi_VT_DaySum') AS vt_kwh,
|
|
47
|
+
sum(em.value) FILTER (WHERE em.var = 'EActi_NT_DaySum') AS nt_kwh,
|
|
48
|
+
-- Coverage is the max day-count across the three vars, not just the total's.
|
|
49
|
+
GREATEST(
|
|
50
|
+
count(*) FILTER (WHERE em.var = 'EActi_VT_NT_DaySum'),
|
|
51
|
+
count(*) FILTER (WHERE em.var = 'EActi_VT_DaySum'),
|
|
52
|
+
count(*) FILTER (WHERE em.var = 'EActi_NT_DaySum')
|
|
53
|
+
) AS days_covered
|
|
54
|
+
FROM enapo_measurements em
|
|
55
|
+
CROSS JOIN bounds b
|
|
56
|
+
WHERE em.source = 'predi_input'
|
|
57
|
+
AND em.var IN ('EActi_VT_NT_DaySum', 'EActi_VT_DaySum', 'EActi_NT_DaySum')
|
|
58
|
+
AND em."timestamp" >= b.month_from_tstz
|
|
59
|
+
AND em."timestamp" < b.month_to_tstz
|
|
60
|
+
GROUP BY em.id, date_trunc('month', em."timestamp" AT TIME ZONE 'Europe/Prague')::date
|
|
61
|
+
),
|
|
62
|
+
|
|
63
|
+
gas_registration AS (
|
|
64
|
+
SELECT DISTINCT ON (em.id, em.device_serial_number)
|
|
65
|
+
em.id,
|
|
66
|
+
em.device_serial_number,
|
|
67
|
+
em.place_id
|
|
68
|
+
FROM enapo_measurements em
|
|
69
|
+
CROSS JOIN bounds b
|
|
70
|
+
WHERE em.source = 'ppas_ave_api'
|
|
71
|
+
AND em.var IN ('core2', 'corediff')
|
|
72
|
+
AND em."timestamp" >= b.month_from_tstz
|
|
73
|
+
GROUP BY em.id, em.device_serial_number, em.place_id
|
|
74
|
+
ORDER BY em.id, em.device_serial_number, max(em."timestamp") DESC, em.place_id DESC
|
|
75
|
+
),
|
|
76
|
+
gas_metered AS (
|
|
77
|
+
SELECT
|
|
78
|
+
em.id AS place_id,
|
|
79
|
+
date_trunc('month', em."timestamp" AT TIME ZONE 'Europe/Prague')::date AS period_start,
|
|
80
|
+
sum(em.value) FILTER (WHERE em.var = 'corediff') AS m3_sum,
|
|
81
|
+
sum(em.value) FILTER (WHERE em.var = 'core2') AS nm3_sum,
|
|
82
|
+
-- Coverage is the max day-count across corediff/core2, not just the winning var's.
|
|
83
|
+
GREATEST(
|
|
84
|
+
count(DISTINCT (em."timestamp" AT TIME ZONE 'Europe/Prague')::date)
|
|
85
|
+
FILTER (WHERE em.var = 'corediff'),
|
|
86
|
+
count(DISTINCT (em."timestamp" AT TIME ZONE 'Europe/Prague')::date)
|
|
87
|
+
FILTER (WHERE em.var = 'core2')
|
|
88
|
+
) AS days_covered
|
|
89
|
+
FROM enapo_measurements em
|
|
90
|
+
CROSS JOIN bounds b
|
|
91
|
+
INNER JOIN gas_registration gr
|
|
92
|
+
ON gr.id = em.id
|
|
93
|
+
AND gr.device_serial_number = em.device_serial_number
|
|
94
|
+
AND gr.place_id = em.place_id
|
|
95
|
+
WHERE em.source = 'ppas_ave_api'
|
|
96
|
+
AND em.var IN ('core2', 'corediff')
|
|
97
|
+
AND em."timestamp" >= b.month_from_tstz
|
|
98
|
+
AND em."timestamp" < b.month_to_tstz
|
|
99
|
+
GROUP BY em.id, date_trunc('month', em."timestamp" AT TIME ZONE 'Europe/Prague')::date
|
|
100
|
+
),
|
|
101
|
+
|
|
102
|
+
distribution_device AS (
|
|
103
|
+
SELECT DISTINCT ON (ins.eic, d.place_id, d.device_serial_number, d.date_from, d.date_to, d.kind, d.unit)
|
|
104
|
+
ins.eic,
|
|
105
|
+
d.place_id,
|
|
106
|
+
d.invoice_id,
|
|
107
|
+
d.date_from,
|
|
108
|
+
d.date_to,
|
|
109
|
+
d.kind,
|
|
110
|
+
d.unit,
|
|
111
|
+
d.consumption,
|
|
112
|
+
d.normometers_nm3,
|
|
113
|
+
d.gas_consumption_kwh,
|
|
114
|
+
d.combustion_heat
|
|
115
|
+
FROM enapo_ppas_distribution_invoice_device d
|
|
116
|
+
INNER JOIN enapo_ppas_distribution_invoice i
|
|
117
|
+
ON i.id = d.invoice_id
|
|
118
|
+
INNER JOIN enapo_ppas_distribution_installation ins
|
|
119
|
+
ON ins.invoice_id = d.invoice_id
|
|
120
|
+
AND ins.customer_id = i.customer_id
|
|
121
|
+
AND ins.place_id = d.place_id
|
|
122
|
+
WHERE COALESCE(i.is_canceled, false) = false
|
|
123
|
+
AND d.date_to >= d.date_from
|
|
124
|
+
AND d.consumption IS NOT NULL
|
|
125
|
+
AND d.kind IN ('ZIZWC', 'ZIABN3')
|
|
126
|
+
AND d.reading_type = 'STANDARD'
|
|
127
|
+
AND NOT EXISTS (
|
|
128
|
+
SELECT 1 FROM enapo_ppas_distribution_invoice s
|
|
129
|
+
WHERE s.preceding_id = i.id AND COALESCE(s.is_canceled, false) = false
|
|
130
|
+
)
|
|
131
|
+
ORDER BY ins.eic, d.place_id, d.device_serial_number, d.date_from, d.date_to, d.kind, d.unit,
|
|
132
|
+
i.facts_doc_date DESC, i.id DESC
|
|
133
|
+
),
|
|
134
|
+
commercial_device AS (
|
|
135
|
+
SELECT DISTINCT ON (ins.eic, d.place_id, d.device_serial_number, d.date_from, d.date_to, d.kind, d.unit)
|
|
136
|
+
ins.eic,
|
|
137
|
+
d.place_id,
|
|
138
|
+
d.invoice_id,
|
|
139
|
+
d.date_from,
|
|
140
|
+
d.date_to,
|
|
141
|
+
d.kind,
|
|
142
|
+
d.unit,
|
|
143
|
+
d.consumption,
|
|
144
|
+
d.normometers_nm3,
|
|
145
|
+
d.gas_consumption_kwh,
|
|
146
|
+
d.combustion_heat
|
|
147
|
+
FROM enapo_ppas_commercial_invoice_device d
|
|
148
|
+
INNER JOIN enapo_ppas_commercial_invoice i
|
|
149
|
+
ON i.id = d.invoice_id
|
|
150
|
+
INNER JOIN enapo_ppas_commercial_invoice_installations ins
|
|
151
|
+
ON ins.invoice_id = d.invoice_id
|
|
152
|
+
AND ins.customer_id = i.customer_id
|
|
153
|
+
AND ins.place_id = d.place_id
|
|
154
|
+
WHERE COALESCE(i.is_canceled, false) = false
|
|
155
|
+
AND d.date_to >= d.date_from
|
|
156
|
+
AND d.consumption IS NOT NULL
|
|
157
|
+
AND d.reading_type = 'STANDARD'
|
|
158
|
+
AND NOT EXISTS (
|
|
159
|
+
SELECT 1 FROM enapo_ppas_commercial_invoice s
|
|
160
|
+
WHERE s.preceding_id = i.id AND COALESCE(s.is_canceled, false) = false
|
|
161
|
+
)
|
|
162
|
+
ORDER BY ins.eic, d.place_id, d.device_serial_number, d.date_from, d.date_to, d.kind, d.unit,
|
|
163
|
+
i.facts_doc_date DESC, i.id DESC
|
|
164
|
+
),
|
|
165
|
+
|
|
166
|
+
invoice_device_month AS (
|
|
167
|
+
SELECT
|
|
168
|
+
'ppas_distribution_invoice' AS source,
|
|
169
|
+
d.eic AS place_id,
|
|
170
|
+
d.invoice_id,
|
|
171
|
+
gs.month::date AS period_start,
|
|
172
|
+
CASE WHEN d.unit = 'KWH' THEN NULL ELSE d.consumption END * o.share AS volume,
|
|
173
|
+
CASE WHEN d.unit = 'NM3' THEN 'Nm3' ELSE 'm3' END AS volume_unit,
|
|
174
|
+
d.normometers_nm3 * o.share AS nm3,
|
|
175
|
+
NULLIF(d.gas_consumption_kwh, 0) * o.share AS kwh,
|
|
176
|
+
(o.share < 1) AS is_estimated,
|
|
177
|
+
o.overlap_days AS days_covered
|
|
178
|
+
FROM distribution_device d
|
|
179
|
+
CROSS JOIN bounds b
|
|
180
|
+
CROSS JOIN LATERAL generate_series(
|
|
181
|
+
date_trunc('month', d.date_from::timestamp),
|
|
182
|
+
date_trunc('month', d.date_to::timestamp),
|
|
183
|
+
interval '1 month'
|
|
184
|
+
) gs(month)
|
|
185
|
+
CROSS JOIN LATERAL (
|
|
186
|
+
SELECT
|
|
187
|
+
ov.overlap_days,
|
|
188
|
+
ov.overlap_days::numeric / NULLIF(d.date_to - d.date_from + 1, 0) AS share
|
|
189
|
+
FROM (
|
|
190
|
+
SELECT LEAST(d.date_to, (gs.month + interval '1 month - 1 day')::date)
|
|
191
|
+
- GREATEST(d.date_from, gs.month::date) + 1 AS overlap_days
|
|
192
|
+
) ov
|
|
193
|
+
) o
|
|
194
|
+
WHERE gs.month >= b.month_from AND gs.month < b.month_to
|
|
195
|
+
|
|
196
|
+
UNION ALL
|
|
197
|
+
|
|
198
|
+
SELECT
|
|
199
|
+
'ppas_commercial_invoice',
|
|
200
|
+
d.eic,
|
|
201
|
+
d.invoice_id,
|
|
202
|
+
gs.month::date,
|
|
203
|
+
CASE WHEN d.unit = 'KWH' THEN NULL ELSE d.consumption END * o.share,
|
|
204
|
+
CASE WHEN d.unit = 'NM3' THEN 'Nm3' ELSE 'm3' END,
|
|
205
|
+
d.normometers_nm3 * o.share,
|
|
206
|
+
NULLIF(d.gas_consumption_kwh, 0) * o.share,
|
|
207
|
+
(o.share < 1),
|
|
208
|
+
o.overlap_days
|
|
209
|
+
FROM commercial_device d
|
|
210
|
+
CROSS JOIN bounds b
|
|
211
|
+
CROSS JOIN LATERAL generate_series(
|
|
212
|
+
date_trunc('month', d.date_from::timestamp),
|
|
213
|
+
date_trunc('month', d.date_to::timestamp),
|
|
214
|
+
interval '1 month'
|
|
215
|
+
) gs(month)
|
|
216
|
+
CROSS JOIN LATERAL (
|
|
217
|
+
SELECT
|
|
218
|
+
ov.overlap_days,
|
|
219
|
+
ov.overlap_days::numeric / NULLIF(d.date_to - d.date_from + 1, 0) AS share
|
|
220
|
+
FROM (
|
|
221
|
+
SELECT LEAST(d.date_to, (gs.month + interval '1 month - 1 day')::date)
|
|
222
|
+
- GREATEST(d.date_from, gs.month::date) + 1 AS overlap_days
|
|
223
|
+
) ov
|
|
224
|
+
) o
|
|
225
|
+
WHERE gs.month >= b.month_from AND gs.month < b.month_to
|
|
226
|
+
),
|
|
227
|
+
invoice_month AS (
|
|
228
|
+
SELECT
|
|
229
|
+
source,
|
|
230
|
+
place_id,
|
|
231
|
+
period_start,
|
|
232
|
+
sum(volume) AS volume,
|
|
233
|
+
max(volume_unit) AS volume_unit,
|
|
234
|
+
sum(nm3) AS nm3,
|
|
235
|
+
sum(kwh) AS kwh,
|
|
236
|
+
bool_or(is_estimated) AS is_estimated,
|
|
237
|
+
-- Clamp to the month's length: sum() would exceed it when meters are billed in parallel.
|
|
238
|
+
LEAST(
|
|
239
|
+
sum(days_covered),
|
|
240
|
+
(period_start + interval '1 month')::date - period_start
|
|
241
|
+
) AS days_covered,
|
|
242
|
+
array_agg(DISTINCT invoice_id::text ORDER BY invoice_id::text) AS invoice_ids
|
|
243
|
+
FROM invoice_device_month
|
|
244
|
+
GROUP BY source, place_id, period_start
|
|
245
|
+
),
|
|
246
|
+
invoice_year AS (
|
|
247
|
+
SELECT
|
|
248
|
+
source,
|
|
249
|
+
place_id,
|
|
250
|
+
date_trunc('year', period_start)::date AS period_start,
|
|
251
|
+
array_agg(DISTINCT invoice_id::text ORDER BY invoice_id::text) AS invoice_ids
|
|
252
|
+
FROM invoice_device_month
|
|
253
|
+
GROUP BY source, place_id, date_trunc('year', period_start)::date
|
|
254
|
+
),
|
|
255
|
+
|
|
256
|
+
gas_combustion_heat AS (
|
|
257
|
+
SELECT DISTINCT ON (d.eic)
|
|
258
|
+
d.eic,
|
|
259
|
+
NULLIF(d.combustion_heat, 0)::numeric AS heat_kwh_per_m3
|
|
260
|
+
FROM distribution_device d
|
|
261
|
+
WHERE NULLIF(d.combustion_heat, 0) IS NOT NULL
|
|
262
|
+
ORDER BY d.eic, d.date_to DESC
|
|
263
|
+
),
|
|
264
|
+
|
|
265
|
+
porsenna_period AS (
|
|
266
|
+
SELECT *
|
|
267
|
+
FROM (
|
|
268
|
+
SELECT
|
|
269
|
+
d.identifier AS place_id,
|
|
270
|
+
c.commodity,
|
|
271
|
+
c."var" AS period_type,
|
|
272
|
+
f_enapo_safe_period(c."var", c."period") AS period_start,
|
|
273
|
+
c.value,
|
|
274
|
+
c.unit,
|
|
275
|
+
c."count" AS days_covered
|
|
276
|
+
FROM enapo_porsenna_consumption c
|
|
277
|
+
INNER JOIN enapo_porsenna_devices d
|
|
278
|
+
ON d.source = c.source AND d.id = c.device_id
|
|
279
|
+
WHERE d.identifier IS NOT NULL
|
|
280
|
+
AND (d."level" IS NULL OR d."level" = 'main')
|
|
281
|
+
AND c.commodity IS NOT NULL
|
|
282
|
+
AND c."var" IN ('yearly', 'monthly')
|
|
283
|
+
) parsed
|
|
284
|
+
WHERE parsed.period_start IS NOT NULL
|
|
285
|
+
),
|
|
286
|
+
|
|
287
|
+
monthly AS (
|
|
288
|
+
SELECT
|
|
289
|
+
p.gid,
|
|
290
|
+
p.place_id,
|
|
291
|
+
p.id_type,
|
|
292
|
+
p.commodity,
|
|
293
|
+
'predi_input'::varchar(50) AS source,
|
|
294
|
+
'monthly'::varchar(10) AS period_type,
|
|
295
|
+
e.period_start,
|
|
296
|
+
COALESCE(e.total_kwh, e.vt_kwh + e.nt_kwh, e.vt_kwh, e.nt_kwh) AS value,
|
|
297
|
+
'kWh'::varchar(10) AS unit,
|
|
298
|
+
COALESCE(e.total_kwh, e.vt_kwh + e.nt_kwh, e.vt_kwh, e.nt_kwh) AS value_kwh,
|
|
299
|
+
'EActi_VT_NT_DaySum'::varchar(50) AS internal_source_var,
|
|
300
|
+
e.days_covered,
|
|
301
|
+
false AS is_estimated,
|
|
302
|
+
'{}'::text[] AS invoice_ids
|
|
303
|
+
FROM point p
|
|
304
|
+
INNER JOIN electricity_metered e ON e.place_id = p.place_id
|
|
305
|
+
WHERE p.commodity = 'electricity'
|
|
306
|
+
|
|
307
|
+
UNION ALL
|
|
308
|
+
|
|
309
|
+
SELECT
|
|
310
|
+
p.gid,
|
|
311
|
+
p.place_id,
|
|
312
|
+
p.id_type,
|
|
313
|
+
p.commodity,
|
|
314
|
+
'ppas_ave_api',
|
|
315
|
+
'monthly',
|
|
316
|
+
g.period_start,
|
|
317
|
+
CASE WHEN g.m3_sum IS NOT NULL THEN g.m3_sum ELSE NULLIF(g.nm3_sum, 0) END,
|
|
318
|
+
CASE WHEN g.m3_sum IS NOT NULL THEN 'm3' ELSE 'Nm3' END,
|
|
319
|
+
(NULLIF(g.nm3_sum, 0) * ch.heat_kwh_per_m3)::numeric,
|
|
320
|
+
CASE WHEN g.m3_sum IS NOT NULL THEN 'corediff' ELSE 'core2' END,
|
|
321
|
+
g.days_covered,
|
|
322
|
+
false,
|
|
323
|
+
'{}'::text[]
|
|
324
|
+
FROM point p
|
|
325
|
+
INNER JOIN gas_metered g ON g.place_id = p.place_id
|
|
326
|
+
LEFT JOIN gas_combustion_heat ch ON ch.eic = p.place_id
|
|
327
|
+
WHERE p.commodity = 'gas'
|
|
328
|
+
|
|
329
|
+
UNION ALL
|
|
330
|
+
|
|
331
|
+
SELECT
|
|
332
|
+
p.gid,
|
|
333
|
+
p.place_id,
|
|
334
|
+
p.id_type,
|
|
335
|
+
p.commodity,
|
|
336
|
+
i.source,
|
|
337
|
+
'monthly',
|
|
338
|
+
i.period_start,
|
|
339
|
+
COALESCE(i.volume, i.nm3::numeric),
|
|
340
|
+
CASE WHEN i.volume IS NOT NULL THEN i.volume_unit ELSE 'Nm3' END,
|
|
341
|
+
i.kwh,
|
|
342
|
+
NULL,
|
|
343
|
+
i.days_covered,
|
|
344
|
+
i.is_estimated,
|
|
345
|
+
i.invoice_ids
|
|
346
|
+
FROM point p
|
|
347
|
+
INNER JOIN invoice_month i ON i.place_id = p.place_id
|
|
348
|
+
WHERE p.commodity = 'gas'
|
|
349
|
+
|
|
350
|
+
UNION ALL
|
|
351
|
+
|
|
352
|
+
SELECT
|
|
353
|
+
p.gid,
|
|
354
|
+
p.place_id,
|
|
355
|
+
p.id_type,
|
|
356
|
+
p.commodity,
|
|
357
|
+
'porsenna',
|
|
358
|
+
'monthly',
|
|
359
|
+
pp.period_start,
|
|
360
|
+
pp.value,
|
|
361
|
+
pp.unit,
|
|
362
|
+
CASE WHEN lower(pp.unit) = 'kwh' THEN pp.value ELSE NULL END,
|
|
363
|
+
NULL,
|
|
364
|
+
pp.days_covered,
|
|
365
|
+
false,
|
|
366
|
+
'{}'::text[]
|
|
367
|
+
FROM point p
|
|
368
|
+
CROSS JOIN bounds b
|
|
369
|
+
INNER JOIN porsenna_period pp
|
|
370
|
+
ON pp.place_id = p.place_id AND pp.commodity = p.commodity
|
|
371
|
+
WHERE pp.period_type = 'monthly'
|
|
372
|
+
AND pp.period_start >= b.month_from::date
|
|
373
|
+
AND pp.period_start < b.month_to::date
|
|
374
|
+
),
|
|
375
|
+
|
|
376
|
+
yearly_rollup AS (
|
|
377
|
+
SELECT
|
|
378
|
+
gid,
|
|
379
|
+
place_id,
|
|
380
|
+
id_type,
|
|
381
|
+
commodity,
|
|
382
|
+
source,
|
|
383
|
+
'yearly'::varchar(10) AS period_type,
|
|
384
|
+
date_trunc('year', period_start)::date AS period_start,
|
|
385
|
+
sum(value) AS value,
|
|
386
|
+
unit,
|
|
387
|
+
-- count(*) = count(value_kwh) is an all-non-null check: only sum value_kwh when every month has one.
|
|
388
|
+
CASE WHEN count(*) = count(value_kwh) THEN sum(value_kwh) END AS value_kwh,
|
|
389
|
+
max(internal_source_var) AS internal_source_var,
|
|
390
|
+
sum(days_covered) AS days_covered,
|
|
391
|
+
bool_or(is_estimated) AS is_estimated
|
|
392
|
+
FROM monthly m
|
|
393
|
+
WHERE NOT (m.source = 'porsenna' AND EXISTS (
|
|
394
|
+
SELECT 1
|
|
395
|
+
FROM porsenna_period pp
|
|
396
|
+
WHERE pp.period_type = 'yearly'
|
|
397
|
+
AND pp.place_id = m.place_id
|
|
398
|
+
AND pp.commodity = m.commodity
|
|
399
|
+
AND pp.period_start = date_trunc('year', m.period_start)::date
|
|
400
|
+
))
|
|
401
|
+
GROUP BY gid, place_id, id_type, commodity, source, date_trunc('year', period_start)::date, unit
|
|
402
|
+
),
|
|
403
|
+
yearly AS (
|
|
404
|
+
SELECT
|
|
405
|
+
r.gid,
|
|
406
|
+
r.place_id,
|
|
407
|
+
r.id_type,
|
|
408
|
+
r.commodity,
|
|
409
|
+
r.source,
|
|
410
|
+
r.period_type,
|
|
411
|
+
r.period_start,
|
|
412
|
+
r.value,
|
|
413
|
+
r.unit,
|
|
414
|
+
r.value_kwh,
|
|
415
|
+
r.internal_source_var,
|
|
416
|
+
r.days_covered,
|
|
417
|
+
r.is_estimated,
|
|
418
|
+
COALESCE(iy.invoice_ids, '{}'::text[]) AS invoice_ids
|
|
419
|
+
FROM yearly_rollup r
|
|
420
|
+
LEFT JOIN invoice_year iy
|
|
421
|
+
ON iy.source = r.source AND iy.place_id = r.place_id AND iy.period_start = r.period_start
|
|
422
|
+
|
|
423
|
+
UNION ALL
|
|
424
|
+
|
|
425
|
+
SELECT
|
|
426
|
+
p.gid,
|
|
427
|
+
p.place_id,
|
|
428
|
+
p.id_type,
|
|
429
|
+
p.commodity,
|
|
430
|
+
'porsenna',
|
|
431
|
+
'yearly',
|
|
432
|
+
pp.period_start,
|
|
433
|
+
pp.value,
|
|
434
|
+
pp.unit,
|
|
435
|
+
CASE WHEN lower(pp.unit) = 'kwh' THEN pp.value ELSE NULL END,
|
|
436
|
+
NULL,
|
|
437
|
+
pp.days_covered,
|
|
438
|
+
false,
|
|
439
|
+
'{}'::text[]
|
|
440
|
+
FROM point p
|
|
441
|
+
INNER JOIN porsenna_period pp
|
|
442
|
+
ON pp.place_id = p.place_id AND pp.commodity = p.commodity
|
|
443
|
+
WHERE pp.period_type = 'yearly'
|
|
444
|
+
)
|
|
445
|
+
|
|
446
|
+
SELECT
|
|
447
|
+
gid::varchar AS gid,
|
|
448
|
+
place_id::varchar(50) AS place_id,
|
|
449
|
+
max(id_type)::varchar(10) AS id_type,
|
|
450
|
+
commodity::varchar(20) AS commodity,
|
|
451
|
+
source::varchar(50) AS source,
|
|
452
|
+
period_type::varchar(10) AS period_type,
|
|
453
|
+
period_start,
|
|
454
|
+
sum(value)::numeric(30, 6) AS value,
|
|
455
|
+
unit::varchar(10) AS unit,
|
|
456
|
+
(CASE WHEN count(*) = count(value_kwh) THEN sum(value_kwh) END)::numeric(30, 6) AS value_kwh,
|
|
457
|
+
max(internal_source_var)::varchar(50) AS internal_source_var,
|
|
458
|
+
COALESCE(max(invoice_ids), '{}'::text[]) AS invoice_ids,
|
|
459
|
+
max(days_covered)::int AS coverage_count,
|
|
460
|
+
(
|
|
461
|
+
CASE period_type
|
|
462
|
+
WHEN 'yearly' THEN (make_date(extract(year FROM period_start)::int + 1, 1, 1) - period_start)
|
|
463
|
+
ELSE (period_start + interval '1 month')::date - period_start
|
|
464
|
+
END
|
|
465
|
+
)::int AS expected_count,
|
|
466
|
+
bool_or(is_estimated) AS is_estimated
|
|
467
|
+
FROM (
|
|
468
|
+
SELECT * FROM monthly
|
|
469
|
+
UNION ALL
|
|
470
|
+
SELECT * FROM yearly
|
|
471
|
+
) all_periods
|
|
472
|
+
WHERE value IS NOT NULL
|
|
473
|
+
GROUP BY gid, place_id, commodity, source, unit, period_type, period_start;
|
|
474
|
+
|
|
475
|
+
COMMENT ON MATERIALIZED VIEW mv_enapo_om_consumption IS
|
|
476
|
+
'Monthly and yearly consumption per consumption point per source, for the last 48 months, behind the DeD building detail endpoint. One row per (gid, place_id, commodity, source, unit, period_type, period_start). Refreshed by EnapoConsumptionHistoryRefreshTask (integration engine).';
|
|
477
|
+
|
|
478
|
+
COMMENT ON COLUMN mv_enapo_om_consumption.place_id IS
|
|
479
|
+
'EAN / EIC / OM code, as in enapo_gid_mapping.place_id - NOT enapo_measurements.place_id, which holds a PPAS-internal place id. Measurements are joined through enapo_measurements.id.';
|
|
480
|
+
COMMENT ON COLUMN mv_enapo_om_consumption.value IS
|
|
481
|
+
'Consumption for the period in `unit`. Electricity is kWh (the upstream T1_Wh_total naming is wrong); metered gas is m3 from corediff, or Nm3 from core2 when corediff is absent; invoiced gas follows the invoice unit; Porsenna carries its own unit.';
|
|
482
|
+
COMMENT ON COLUMN mv_enapo_om_consumption.value_kwh IS
|
|
483
|
+
'Derived comparable energy: for gas, normometers_nm3 * combustion_heat (verified exact). NULL when the conversion inputs are missing - `value` + `unit` stay authoritative.';
|
|
484
|
+
COMMENT ON COLUMN mv_enapo_om_consumption.internal_source_var IS
|
|
485
|
+
'Which enapo_measurements.var produced the row; NULL for invoice and Porsenna rows. Provenance for debugging, not part of the public response.';
|
|
486
|
+
COMMENT ON COLUMN mv_enapo_om_consumption.invoice_ids IS
|
|
487
|
+
'Billing documents the row was allocated from, sorted and deduplicated; empty for metered and Porsenna rows. A period can be allocated from several invoices (a yearly roll-up usually is), which is why it is an array.';
|
|
488
|
+
COMMENT ON COLUMN mv_enapo_om_consumption.coverage_count IS
|
|
489
|
+
'Days of the period that carry data. Days for every commodity and both period types, so it is comparable with expected_count.';
|
|
490
|
+
COMMENT ON COLUMN mv_enapo_om_consumption.expected_count IS 'Days in the period (28-31, or 365/366).';
|
|
491
|
+
COMMENT ON COLUMN mv_enapo_om_consumption.is_estimated IS
|
|
492
|
+
'True when the value was allocated pro rata from a billing period spanning more than one month, rather than read for the period itself.';
|
|
493
|
+
|
|
494
|
+
COMMENT ON COLUMN enapo_porsenna_consumption.commodity IS
|
|
495
|
+
'Normalised commodity name derived from the Porsenna gauge type by PorsennaConsumptionTransformation.extractCommodity: electricity | gas | heat | water (electricity_meter -> electricity, gasometer -> gas, ...). NULL when the gauge type maps to none of them.';
|
|
496
|
+
|
|
497
|
+
CREATE UNIQUE INDEX mv_enapo_om_consumption_uidx
|
|
498
|
+
ON mv_enapo_om_consumption (gid, place_id, commodity, source, unit, period_type, period_start);
|
|
499
|
+
|
|
500
|
+
CREATE INDEX mv_enapo_om_consumption_gid_period_idx
|
|
501
|
+
ON mv_enapo_om_consumption (gid, period_type, period_start);
|
|
502
|
+
|
|
503
|
+
CREATE INDEX IF NOT EXISTS enapo_measurements_source_var_ts_idx
|
|
504
|
+
ON enapo_measurements (source, var, "timestamp");
|
|
@@ -18,6 +18,7 @@ const EnoBuildingRepository_1 = require("../repositories/eno/EnoBuildingReposito
|
|
|
18
18
|
const EnoEJRepository_1 = require("../repositories/eno/EnoEJRepository");
|
|
19
19
|
const EnoGeometryRepository_1 = require("../repositories/eno/EnoGeometryRepository");
|
|
20
20
|
const DedSearchIndexRepository_1 = require("../repositories/DedSearchIndexRepository");
|
|
21
|
+
const EnapoConsumptionHistoryIndexRepository_1 = require("../repositories/EnapoConsumptionHistoryIndexRepository");
|
|
21
22
|
const EnoLocationRepository_1 = require("../repositories/eno/EnoLocationRepository");
|
|
22
23
|
const EnoManagerRepository_1 = require("../repositories/eno/EnoManagerRepository");
|
|
23
24
|
const EnoOrganizationRepository_1 = require("../repositories/eno/EnoOrganizationRepository");
|
|
@@ -55,6 +56,7 @@ const EnapoPrediTask_1 = require("../workers/task/EnapoPrediTask");
|
|
|
55
56
|
const EnoBuildingTask_1 = require("../workers/task/EnoBuildingTask");
|
|
56
57
|
const EnoGeometryTask_1 = require("../workers/task/EnoGeometryTask");
|
|
57
58
|
const DedSearchIndexRefreshTask_1 = require("../workers/task/DedSearchIndexRefreshTask");
|
|
59
|
+
const EnapoConsumptionHistoryRefreshTask_1 = require("../workers/task/EnapoConsumptionHistoryRefreshTask");
|
|
58
60
|
const EnoLookupTask_1 = require("../workers/task/EnoLookupTask");
|
|
59
61
|
const EnoStructureTask_1 = require("../workers/task/EnoStructureTask");
|
|
60
62
|
const PorsennaDistributionTask_1 = require("../workers/task/PorsennaDistributionTask");
|
|
@@ -88,6 +90,7 @@ EnapoContainer.register(EnapoWorkerContainerToken_1.EnapoWorkerContainerToken.En
|
|
|
88
90
|
.register(EnapoWorkerContainerToken_1.EnapoWorkerContainerToken.EnoStructureRepository, EnoStructureRepository_1.EnoStructureRepository)
|
|
89
91
|
.register(EnapoWorkerContainerToken_1.EnapoWorkerContainerToken.EnoGeometryRepository, EnoGeometryRepository_1.EnoGeometryRepository)
|
|
90
92
|
.register(EnapoWorkerContainerToken_1.EnapoWorkerContainerToken.DedSearchIndexRepository, DedSearchIndexRepository_1.DedSearchIndexRepository)
|
|
93
|
+
.register(EnapoWorkerContainerToken_1.EnapoWorkerContainerToken.EnapoConsumptionHistoryIndexRepository, EnapoConsumptionHistoryIndexRepository_1.EnapoConsumptionHistoryIndexRepository)
|
|
91
94
|
.register(EnapoWorkerContainerToken_1.EnapoWorkerContainerToken.PpasDistributionInvoiceDeviceRepository, PpasDistributionInvoiceDeviceRepository_1.PpasDistributionInvoiceDeviceRepository)
|
|
92
95
|
.register(EnapoWorkerContainerToken_1.EnapoWorkerContainerToken.PpasDistributionInvoiceInstallationRepository, PpasDistributionInvoiceInstallationRepository_1.PpasDistributionInvoiceInstallationRepository)
|
|
93
96
|
.register(EnapoWorkerContainerToken_1.EnapoWorkerContainerToken.PpasDistributionInvoicePriceRepository, PpasDistributionInvoicePriceRepository_1.PpasDistributionInvoicePriceRepository)
|
|
@@ -124,5 +127,6 @@ EnapoContainer.register(EnapoWorkerContainerToken_1.EnapoWorkerContainerToken.En
|
|
|
124
127
|
.register(EnapoWorkerContainerToken_1.EnapoWorkerContainerToken.EnapoPpasDistributionTask, EnapoPpasDistributionTask_1.EnapoPpasDistributionTask)
|
|
125
128
|
.register(EnapoWorkerContainerToken_1.EnapoWorkerContainerToken.EnapoPpasCommercialTask, EnapoPpasCommercialTask_1.EnapoPpasCommercialTask)
|
|
126
129
|
.register(EnapoWorkerContainerToken_1.EnapoWorkerContainerToken.PorsennaDistributionTask, PorsennaDistributionTask_1.PorsennaDistributionTask)
|
|
127
|
-
.register(EnapoWorkerContainerToken_1.EnapoWorkerContainerToken.DedSearchIndexRefreshTask, DedSearchIndexRefreshTask_1.DedSearchIndexRefreshTask)
|
|
130
|
+
.register(EnapoWorkerContainerToken_1.EnapoWorkerContainerToken.DedSearchIndexRefreshTask, DedSearchIndexRefreshTask_1.DedSearchIndexRefreshTask)
|
|
131
|
+
.register(EnapoWorkerContainerToken_1.EnapoWorkerContainerToken.EnapoConsumptionHistoryRefreshTask, EnapoConsumptionHistoryRefreshTask_1.EnapoConsumptionHistoryRefreshTask);
|
|
128
132
|
//# sourceMappingURL=Di.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Di.js","sourceRoot":"","sources":["../../../../src/integration-engine/enapo/ioc/Di.ts"],"names":[],"mappings":";;;AAAA,iIAA4H;AAC5H,qHAAgH;AAChH,kIAA6H;AAC7H,6FAAwF;AACxF,qEAA0F;AAE1F,kFAA+E;AAC/E,mGAAgG;AAChG,mFAAgF;AAChF,sGAAmG;AACnG,4GAAyG;AACzG,6FAA0F;AAC1F,+FAA4F;AAC5F,mFAAgF;AAChF,qFAAkF;AAClF,yEAAsE;AACtE,qFAAkF;AAClF,uFAAoF;AACpF,qFAAkF;AAClF,mFAAgF;AAChF,6FAA0F;AAC1F,qFAAkF;AAClF,yFAAsF;AACtF,uFAAoF;AACpF,+FAA4F;AAC5F,sGAAmG;AACnG,0GAAuG;AACvG,kGAA+F;AAC/F,sHAAmH;AACnH,kIAA+H;AAC/H,oHAAiH;AACjH,0GAAuG;AACvG,0HAAuH;AACvH,sIAAmI;AACnI,wHAAqH;AACrH,8GAA2G;AAC3G,oGAAiG;AACjG,oFAAiF;AACjF,8FAA2F;AAC3F,wGAAqG;AACrG,0GAAuG;AACvG,qHAAkH;AAClH,yGAAsG;AACtG,uGAAoG;AACpG,2GAAwG;AACxG,kHAA+G;AAC/G,wGAAqG;AACrG,gGAA6F;AAC7F,qFAAkF;AAClF,yFAAsF;AACtF,iEAA8D;AAC9D,mEAAgE;AAChE,qEAAkE;AAClE,qEAAkE;AAClE,yFAAsF;AACtF,iEAA8D;AAC9D,uEAAoE;AACpE,uFAAoF;AACpF,2EAAwE;AAExE,wBAAwB;AACxB,MAAM,cAAc,GAAwB,+BAA0B,CAAC,oBAAoB,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"Di.js","sourceRoot":"","sources":["../../../../src/integration-engine/enapo/ioc/Di.ts"],"names":[],"mappings":";;;AA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AAC,kCAAkC,EAAE,uEAAkC,CAAC,CAAC"}
|
|
@@ -48,10 +48,12 @@ declare const EnapoWorkerContainerToken: {
|
|
|
48
48
|
EnoStructureRepository: symbol;
|
|
49
49
|
EnoGeometryRepository: symbol;
|
|
50
50
|
DedSearchIndexRepository: symbol;
|
|
51
|
+
EnapoConsumptionHistoryIndexRepository: symbol;
|
|
51
52
|
EnoLookupTask: symbol;
|
|
52
53
|
EnoBuildingTask: symbol;
|
|
53
54
|
EnoStructureTask: symbol;
|
|
54
55
|
EnoGeometryTask: symbol;
|
|
55
56
|
DedSearchIndexRefreshTask: symbol;
|
|
57
|
+
EnapoConsumptionHistoryRefreshTask: symbol;
|
|
56
58
|
};
|
|
57
59
|
export { EnapoWorkerContainerToken };
|
|
@@ -60,11 +60,13 @@ const EnapoWorkerContainerToken = {
|
|
|
60
60
|
EnoStructureRepository: Symbol(),
|
|
61
61
|
EnoGeometryRepository: Symbol(),
|
|
62
62
|
DedSearchIndexRepository: Symbol(),
|
|
63
|
+
EnapoConsumptionHistoryIndexRepository: Symbol(),
|
|
63
64
|
EnoLookupTask: Symbol(),
|
|
64
65
|
EnoBuildingTask: Symbol(),
|
|
65
66
|
EnoStructureTask: Symbol(),
|
|
66
67
|
EnoGeometryTask: Symbol(),
|
|
67
68
|
DedSearchIndexRefreshTask: Symbol(),
|
|
69
|
+
EnapoConsumptionHistoryRefreshTask: Symbol(),
|
|
68
70
|
//#endregion
|
|
69
71
|
};
|
|
70
72
|
exports.EnapoWorkerContainerToken = EnapoWorkerContainerToken;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnapoWorkerContainerToken.js","sourceRoot":"","sources":["../../../../src/integration-engine/enapo/ioc/EnapoWorkerContainerToken.ts"],"names":[],"mappings":";;;AAAA,MAAM,yBAAyB,GAAG;IAC9B,oBAAoB;IACpB,kCAAkC,EAAE,MAAM,EAAE;IAC5C,+BAA+B,EAAE,MAAM,EAAE;IACzC,6BAA6B,EAAE,MAA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0B,EAAE,MAAM,EAAE;IACpC,yBAAyB,EAAE,MAAM,EAAE;IACnC,oBAAoB,EAAE,MAAM,EAAE;IAC9B,eAAe,EAAE,MAAM,EAAE;IACzB,qBAAqB,EAAE,MAAM,EAAE;IAC/B,oBAAoB,EAAE,MAAM,EAAE;IAC9B,qBAAqB,EAAE,MAAM,EAAE;IAC/B,qBAAqB,EAAE,MAAM,EAAE;IAC/B,uBAAuB,EAAE,MAAM,EAAE;IACjC,sBAAsB,EAAE,MAAM,EAAE;IAChC,qBAAqB,EAAE,MAAM,EAAE;IAC/B,wBAAwB,EAAE,MAAM,EAAE;
|
|
1
|
+
{"version":3,"file":"EnapoWorkerContainerToken.js","sourceRoot":"","sources":["../../../../src/integration-engine/enapo/ioc/EnapoWorkerContainerToken.ts"],"names":[],"mappings":";;;AAAA,MAAM,yBAAyB,GAAG;IAC9B,oBAAoB;IACpB,kCAAkC,EAAE,MAAM,EAAE;IAC5C,+BAA+B,EAAE,MAAM,EAAE;IACzC,6BAA6B,EAAE,MAAM,EAAE;IACvC,kBAAkB,EAAE,MAAM,EAAE;IAC5B,0BAA0B,EAAE,MAAM,EAAE;IACpC,YAAY;IAEZ,sBAAsB;IACtB,2BAA2B,EAAE,MAAM,EAAE;IACrC,uBAAuB,EAAE,MAAM,EAAE;IACjC,4BAA4B,EAAE,MAAM,EAAE;IACtC,uCAAuC,EAAE,MAAM,EAAE;IACjD,6CAA6C,EAAE,MAAM,EAAE;IACvD,sCAAsC,EAAE,MAAM,EAAE;IAChD,iCAAiC,EAAE,MAAM,EAAE;IAC3C,+BAA+B,EAAE,MAAM,EAAE;IACzC,2CAA2C,EAAE,MAAM,EAAE;IACrD,qCAAqC,EAAE,MAAM,EAAE;IAC/C,oCAAoC,EAAE,MAAM,EAAE;IAC9C,2BAA2B,EAAE,MAAM,EAAE;IACrC,6BAA6B,EAAE,MAAM,EAAE;IACvC,yBAAyB,EAAE,MAAM,EAAE;IACnC,YAAY;IAEZ,yBAAyB;IACzB,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MAAM,EAAE;IAC5C,YAAY;CACf,CAAC;AAEO,8DAAyB"}
|
package/dist/integration-engine/enapo/repositories/AbstractMaterializedViewIndexRepository.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IDatabaseConnector } from "@golemio/core/dist/helpers/data-access/postgres/IDatabaseConnector";
|
|
2
|
+
export declare abstract class AbstractMaterializedViewIndexRepository {
|
|
3
|
+
private connector;
|
|
4
|
+
private viewName;
|
|
5
|
+
private errorMessage;
|
|
6
|
+
constructor(connector: IDatabaseConnector, viewName: string, errorMessage: string);
|
|
7
|
+
refresh(): Promise<void>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AbstractMaterializedViewIndexRepository = void 0;
|
|
4
|
+
const constants_1 = require("../../../schema-definitions/constants");
|
|
5
|
+
const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
|
|
6
|
+
const sequelize_1 = require("@golemio/core/dist/shared/sequelize");
|
|
7
|
+
class AbstractMaterializedViewIndexRepository {
|
|
8
|
+
constructor(connector, viewName, errorMessage) {
|
|
9
|
+
this.connector = connector;
|
|
10
|
+
this.viewName = viewName;
|
|
11
|
+
this.errorMessage = errorMessage;
|
|
12
|
+
}
|
|
13
|
+
async refresh() {
|
|
14
|
+
try {
|
|
15
|
+
await this.connector
|
|
16
|
+
.getConnection()
|
|
17
|
+
.query(`REFRESH MATERIALIZED VIEW CONCURRENTLY ${constants_1.PG_SCHEMA}.${this.viewName}`, { type: sequelize_1.QueryTypes.RAW });
|
|
18
|
+
}
|
|
19
|
+
catch (err) {
|
|
20
|
+
throw new golemio_errors_1.GeneralError(this.errorMessage, this.constructor.name, err);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.AbstractMaterializedViewIndexRepository = AbstractMaterializedViewIndexRepository;
|
|
25
|
+
//# sourceMappingURL=AbstractMaterializedViewIndexRepository.js.map
|
package/dist/integration-engine/enapo/repositories/AbstractMaterializedViewIndexRepository.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AbstractMaterializedViewIndexRepository.js","sourceRoot":"","sources":["../../../../src/integration-engine/enapo/repositories/AbstractMaterializedViewIndexRepository.ts"],"names":[],"mappings":";;;AAAA,qEAA2C;AAE3C,6EAAwE;AACxE,mEAAiE;AAEjE,MAAsB,uCAAuC;IACzD,YAAoB,SAA6B,EAAU,QAAgB,EAAU,YAAoB;QAArF,cAAS,GAAT,SAAS,CAAoB;QAAU,aAAQ,GAAR,QAAQ,CAAQ;QAAU,iBAAY,GAAZ,YAAY,CAAQ;IAAG,CAAC;IAEtG,KAAK,CAAC,OAAO;QAChB,IAAI,CAAC;YACD,MAAM,IAAI,CAAC,SAAS;iBACf,aAAa,EAAE;iBACf,KAAK,CAAC,0CAA0C,qBAAS,IAAI,IAAI,CAAC,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,sBAAU,CAAC,GAAG,EAAE,CAAC,CAAC;QACjH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,MAAM,IAAI,6BAAY,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAC1E,CAAC;IACL,CAAC;CACJ;AAZD,0FAYC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { IDatabaseConnector } from "@golemio/core/dist/helpers/data-access/postgres/IDatabaseConnector";
|
|
2
|
+
import { AbstractMaterializedViewIndexRepository } from "./AbstractMaterializedViewIndexRepository";
|
|
2
3
|
import { IDedSearchIndexRepository } from "./interfaces/IDedSearchIndexRepository";
|
|
3
|
-
export declare class DedSearchIndexRepository implements IDedSearchIndexRepository {
|
|
4
|
-
private connector;
|
|
4
|
+
export declare class DedSearchIndexRepository extends AbstractMaterializedViewIndexRepository implements IDedSearchIndexRepository {
|
|
5
5
|
constructor(connector: IDatabaseConnector);
|
|
6
|
-
refresh(): Promise<void>;
|
|
7
6
|
}
|