@golemio/flow 1.0.7 → 1.0.8-dev.577679507

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 (36) hide show
  1. package/db/example/.config.json +3 -0
  2. package/db/example/00_truncate_tables.sql +10 -0
  3. package/db/example/01_wifiHistoricData.sql +49 -0
  4. package/db/example/02_countersData.sql +99 -0
  5. package/db/example/03_flowData.sql +343 -0
  6. package/db/example/99_runUpdateProcedure.sql +1 -0
  7. package/db/migrations/postgresql/.config.json +3 -0
  8. package/db/migrations/postgresql/20220616144407-flow.js +53 -0
  9. package/db/migrations/postgresql/package.json +3 -0
  10. package/db/migrations/postgresql/sqls/20220616144407-flow-down.sql +15 -0
  11. package/db/migrations/postgresql/sqls/20220616144407-flow-up.sql +467 -0
  12. package/db/migrations/postgresql/sqls/package.json +3 -0
  13. package/dist/integration-engine/CountersWorker.d.ts +14 -0
  14. package/dist/integration-engine/CountersWorker.js +120 -0
  15. package/dist/integration-engine/CountersWorker.js.map +1 -0
  16. package/dist/integration-engine/FlowWorker.js +6 -2
  17. package/dist/integration-engine/FlowWorker.js.map +1 -1
  18. package/dist/integration-engine/queueDefinitions.js +27 -0
  19. package/dist/integration-engine/queueDefinitions.js.map +1 -1
  20. package/dist/integration-engine/transformations/EcoCounterMeasurementsTransformation.d.ts +6 -0
  21. package/dist/integration-engine/transformations/EcoCounterMeasurementsTransformation.js +42 -0
  22. package/dist/integration-engine/transformations/EcoCounterMeasurementsTransformation.js.map +1 -0
  23. package/dist/integration-engine/transformations/EcoCounterTransformation.d.ts +17 -0
  24. package/dist/integration-engine/transformations/EcoCounterTransformation.js +99 -0
  25. package/dist/integration-engine/transformations/EcoCounterTransformation.js.map +1 -0
  26. package/dist/output-gateway/models/PedestriansLocationsModel.js +4 -2
  27. package/dist/output-gateway/models/PedestriansLocationsModel.js.map +1 -1
  28. package/dist/output-gateway/models/PedestriansMeasurementsModel.js +4 -2
  29. package/dist/output-gateway/models/PedestriansMeasurementsModel.js.map +1 -1
  30. package/dist/schema-definitions/index.d.ts +185 -0
  31. package/dist/schema-definitions/index.js +197 -2
  32. package/dist/schema-definitions/index.js.map +1 -1
  33. package/docs/assets/flow_erd.png +0 -0
  34. package/docs/implementation_documentation_CZ.md +157 -0
  35. package/docs/implementation_documentation_Counters.md +166 -0
  36. package/package.json +62 -58
@@ -0,0 +1,467 @@
1
+ CREATE TABLE flow_analytics (
2
+ id int4 NOT NULL,
3
+ "name" varchar(150) NULL,
4
+ sequence_number int4 NOT NULL,
5
+ create_batch_id int8 NULL,
6
+ created_at timestamptz NULL,
7
+ created_by varchar(150) NULL,
8
+ update_batch_id int8 NULL,
9
+ updated_at timestamptz NULL,
10
+ updated_by varchar(150) NULL,
11
+ CONSTRAINT flow_analyticspkey PRIMARY KEY (id, sequence_number)
12
+ );
13
+
14
+ CREATE TABLE flow_cubes (
15
+ id int4 NOT NULL,
16
+ "name" varchar(150) NOT NULL,
17
+ create_batch_id int8 NULL,
18
+ created_at timestamptz NULL,
19
+ created_by varchar(150) NULL,
20
+ update_batch_id int8 NULL,
21
+ updated_at timestamptz NULL,
22
+ updated_by varchar(150) NULL,
23
+ CONSTRAINT flow_cubespkey PRIMARY KEY (id, name)
24
+ );
25
+
26
+ CREATE TABLE flow_measurements (
27
+ sink_id int4 NOT NULL,
28
+ cube_id int4 NOT NULL,
29
+ sequence_number int4 NOT NULL,
30
+ analytic_id int4 NOT NULL,
31
+ start_timestamp int8 NOT NULL,
32
+ end_timestamp int8 NOT NULL,
33
+ category varchar(150) NOT NULL,
34
+ value int4 NOT NULL,
35
+ create_batch_id int8 NULL,
36
+ created_at timestamptz NULL,
37
+ created_by varchar(150) NULL,
38
+ update_batch_id int8 NULL,
39
+ updated_at timestamptz NULL,
40
+ updated_by varchar(150) NULL,
41
+ data_validity varchar(50) NULL,
42
+ CONSTRAINT flow_measurementspkey PRIMARY KEY (cube_id, sink_id, start_timestamp, end_timestamp, category, sequence_number)
43
+ )
44
+ PARTITION BY RANGE (start_timestamp);
45
+
46
+
47
+ CREATE INDEX flow_measurements_ceated_at ON flow_measurements USING btree (created_at);
48
+ CREATE INDEX flow_measurements_start_cube_sink ON flow_measurements USING btree (cube_id, sink_id);
49
+ CREATE INDEX flow_measurements_start_timestamp ON flow_measurements USING btree (start_timestamp);
50
+
51
+ -- partitions
52
+ CREATE TABLE flow_measurements_min PARTITION OF flow_measurements FOR VALUES FROM (MINVALUE) TO (extract ('epoch' from '2020-09-01'::timestamp)*1000);
53
+ CREATE TABLE flow_measurements_y2020m09 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2020-09-01'::timestamp)*1000) TO (extract ('epoch' from '2020-10-01'::timestamp)*1000);
54
+ CREATE TABLE flow_measurements_y2020m10 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2020-10-01'::timestamp)*1000) TO (extract ('epoch' from '2020-11-01'::timestamp)*1000);
55
+ CREATE TABLE flow_measurements_y2020m11 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2020-11-01'::timestamp)*1000) TO (extract ('epoch' from '2020-12-01'::timestamp)*1000);
56
+ CREATE TABLE flow_measurements_y2020m12 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2020-12-01'::timestamp)*1000) TO (extract ('epoch' from '2021-01-01'::timestamp)*1000);
57
+ --2021
58
+ CREATE TABLE flow_measurements_y2021m01 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2021-01-01'::timestamp)*1000) TO (extract ('epoch' from '2021-02-01'::timestamp)*1000);
59
+ CREATE TABLE flow_measurements_y2021m02 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2021-02-01'::timestamp)*1000) TO (extract ('epoch' from '2021-03-01'::timestamp)*1000);
60
+ CREATE TABLE flow_measurements_y2021m03 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2021-03-01'::timestamp)*1000) TO (extract ('epoch' from '2021-04-01'::timestamp)*1000);
61
+ CREATE TABLE flow_measurements_y2021m04 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2021-04-01'::timestamp)*1000) TO (extract ('epoch' from '2021-05-01'::timestamp)*1000);
62
+ CREATE TABLE flow_measurements_y2021m05 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2021-05-01'::timestamp)*1000) TO (extract ('epoch' from '2021-06-01'::timestamp)*1000);
63
+ CREATE TABLE flow_measurements_y2021m06 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2021-06-01'::timestamp)*1000) TO (extract ('epoch' from '2021-07-01'::timestamp)*1000);
64
+ CREATE TABLE flow_measurements_y2021m07 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2021-07-01'::timestamp)*1000) TO (extract ('epoch' from '2021-08-01'::timestamp)*1000);
65
+ CREATE TABLE flow_measurements_y2021m08 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2021-08-01'::timestamp)*1000) TO (extract ('epoch' from '2021-09-01'::timestamp)*1000);
66
+ CREATE TABLE flow_measurements_y2021m09 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2021-09-01'::timestamp)*1000) TO (extract ('epoch' from '2021-10-01'::timestamp)*1000);
67
+ CREATE TABLE flow_measurements_y2021m10 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2021-10-01'::timestamp)*1000) TO (extract ('epoch' from '2021-11-01'::timestamp)*1000);
68
+ CREATE TABLE flow_measurements_y2021m11 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2021-11-01'::timestamp)*1000) TO (extract ('epoch' from '2021-12-01'::timestamp)*1000);
69
+ CREATE TABLE flow_measurements_y2021m12 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2021-12-01'::timestamp)*1000) TO (extract ('epoch' from '2022-01-01'::timestamp)*1000);
70
+ --2022
71
+ CREATE TABLE flow_measurements_y2022m01 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2022-01-01'::timestamp)*1000) TO (extract ('epoch' from '2022-02-01'::timestamp)*1000);
72
+ CREATE TABLE flow_measurements_y2022m02 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2022-02-01'::timestamp)*1000) TO (extract ('epoch' from '2022-03-01'::timestamp)*1000);
73
+ CREATE TABLE flow_measurements_y2022m03 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2022-03-01'::timestamp)*1000) TO (extract ('epoch' from '2022-04-01'::timestamp)*1000);
74
+ CREATE TABLE flow_measurements_y2022m04 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2022-04-01'::timestamp)*1000) TO (extract ('epoch' from '2022-05-01'::timestamp)*1000);
75
+ CREATE TABLE flow_measurements_y2022m05 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2022-05-01'::timestamp)*1000) TO (extract ('epoch' from '2022-06-01'::timestamp)*1000);
76
+ CREATE TABLE flow_measurements_y2022m06 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2022-06-01'::timestamp)*1000) TO (extract ('epoch' from '2022-07-01'::timestamp)*1000);
77
+ CREATE TABLE flow_measurements_y2022m07 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2022-07-01'::timestamp)*1000) TO (extract ('epoch' from '2022-08-01'::timestamp)*1000);
78
+ CREATE TABLE flow_measurements_y2022m08 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2022-08-01'::timestamp)*1000) TO (extract ('epoch' from '2022-09-01'::timestamp)*1000);
79
+ CREATE TABLE flow_measurements_y2022m09 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2022-09-01'::timestamp)*1000) TO (extract ('epoch' from '2022-10-01'::timestamp)*1000);
80
+ CREATE TABLE flow_measurements_y2022m10 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2022-10-01'::timestamp)*1000) TO (extract ('epoch' from '2022-11-01'::timestamp)*1000);
81
+ CREATE TABLE flow_measurements_y2022m11 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2022-11-01'::timestamp)*1000) TO (extract ('epoch' from '2022-12-01'::timestamp)*1000);
82
+ CREATE TABLE flow_measurements_y2022m12 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2022-12-01'::timestamp)*1000) TO (extract ('epoch' from '2023-01-01'::timestamp)*1000);
83
+ --2023
84
+ CREATE TABLE flow_measurements_y2023m01 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2023-01-01'::timestamp)*1000) TO (extract ('epoch' from '2023-02-01'::timestamp)*1000);
85
+ CREATE TABLE flow_measurements_y2023m02 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2023-02-01'::timestamp)*1000) TO (extract ('epoch' from '2023-03-01'::timestamp)*1000);
86
+ CREATE TABLE flow_measurements_y2023m03 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2023-03-01'::timestamp)*1000) TO (extract ('epoch' from '2023-04-01'::timestamp)*1000);
87
+ CREATE TABLE flow_measurements_y2023m04 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2023-04-01'::timestamp)*1000) TO (extract ('epoch' from '2023-05-01'::timestamp)*1000);
88
+ CREATE TABLE flow_measurements_y2023m05 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2023-05-01'::timestamp)*1000) TO (extract ('epoch' from '2023-06-01'::timestamp)*1000);
89
+ CREATE TABLE flow_measurements_y2023m06 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2023-06-01'::timestamp)*1000) TO (extract ('epoch' from '2023-07-01'::timestamp)*1000);
90
+ CREATE TABLE flow_measurements_y2023m07 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2023-07-01'::timestamp)*1000) TO (extract ('epoch' from '2023-08-01'::timestamp)*1000);
91
+ CREATE TABLE flow_measurements_y2023m08 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2023-08-01'::timestamp)*1000) TO (extract ('epoch' from '2023-09-01'::timestamp)*1000);
92
+ CREATE TABLE flow_measurements_y2023m09 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2023-09-01'::timestamp)*1000) TO (extract ('epoch' from '2023-10-01'::timestamp)*1000);
93
+ CREATE TABLE flow_measurements_y2023m10 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2023-10-01'::timestamp)*1000) TO (extract ('epoch' from '2023-11-01'::timestamp)*1000);
94
+ CREATE TABLE flow_measurements_y2023m11 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2023-11-01'::timestamp)*1000) TO (extract ('epoch' from '2023-12-01'::timestamp)*1000);
95
+ CREATE TABLE flow_measurements_y2023m12 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2023-12-01'::timestamp)*1000) TO (extract ('epoch' from '2024-01-01'::timestamp)*1000);
96
+ --2024
97
+ CREATE TABLE flow_measurements_y2024m01 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2024-01-01'::timestamp)*1000) TO (extract ('epoch' from '2024-02-01'::timestamp)*1000);
98
+ CREATE TABLE flow_measurements_y2024m02 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2024-02-01'::timestamp)*1000) TO (extract ('epoch' from '2024-03-01'::timestamp)*1000);
99
+ CREATE TABLE flow_measurements_y2024m03 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2024-03-01'::timestamp)*1000) TO (extract ('epoch' from '2024-04-01'::timestamp)*1000);
100
+ CREATE TABLE flow_measurements_y2024m04 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2024-04-01'::timestamp)*1000) TO (extract ('epoch' from '2024-05-01'::timestamp)*1000);
101
+ CREATE TABLE flow_measurements_y2024m05 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2024-05-01'::timestamp)*1000) TO (extract ('epoch' from '2024-06-01'::timestamp)*1000);
102
+ CREATE TABLE flow_measurements_y2024m06 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2024-06-01'::timestamp)*1000) TO (extract ('epoch' from '2024-07-01'::timestamp)*1000);
103
+ CREATE TABLE flow_measurements_y2024m07 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2024-07-01'::timestamp)*1000) TO (extract ('epoch' from '2024-08-01'::timestamp)*1000);
104
+ CREATE TABLE flow_measurements_y2024m08 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2024-08-01'::timestamp)*1000) TO (extract ('epoch' from '2024-09-01'::timestamp)*1000);
105
+ CREATE TABLE flow_measurements_y2024m09 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2024-09-01'::timestamp)*1000) TO (extract ('epoch' from '2024-10-01'::timestamp)*1000);
106
+ CREATE TABLE flow_measurements_y2024m10 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2024-10-01'::timestamp)*1000) TO (extract ('epoch' from '2024-11-01'::timestamp)*1000);
107
+ CREATE TABLE flow_measurements_y2024m11 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2024-11-01'::timestamp)*1000) TO (extract ('epoch' from '2024-12-01'::timestamp)*1000);
108
+ CREATE TABLE flow_measurements_y2024m12 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2024-12-01'::timestamp)*1000) TO (extract ('epoch' from '2025-01-01'::timestamp)*1000);
109
+ --2025
110
+ CREATE TABLE flow_measurements_y2025m01 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2025-01-01'::timestamp)*1000) TO (extract ('epoch' from '2025-02-01'::timestamp)*1000);
111
+ CREATE TABLE flow_measurements_y2025m02 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2025-02-01'::timestamp)*1000) TO (extract ('epoch' from '2025-03-01'::timestamp)*1000);
112
+ CREATE TABLE flow_measurements_y2025m03 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2025-03-01'::timestamp)*1000) TO (extract ('epoch' from '2025-04-01'::timestamp)*1000);
113
+ CREATE TABLE flow_measurements_y2025m04 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2025-04-01'::timestamp)*1000) TO (extract ('epoch' from '2025-05-01'::timestamp)*1000);
114
+ CREATE TABLE flow_measurements_y2025m05 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2025-05-01'::timestamp)*1000) TO (extract ('epoch' from '2025-06-01'::timestamp)*1000);
115
+ CREATE TABLE flow_measurements_y2025m06 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2025-06-01'::timestamp)*1000) TO (extract ('epoch' from '2025-07-01'::timestamp)*1000);
116
+ CREATE TABLE flow_measurements_y2025m07 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2025-07-01'::timestamp)*1000) TO (extract ('epoch' from '2025-08-01'::timestamp)*1000);
117
+ CREATE TABLE flow_measurements_y2025m08 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2025-08-01'::timestamp)*1000) TO (extract ('epoch' from '2025-09-01'::timestamp)*1000);
118
+ CREATE TABLE flow_measurements_y2025m09 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2025-09-01'::timestamp)*1000) TO (extract ('epoch' from '2025-10-01'::timestamp)*1000);
119
+ CREATE TABLE flow_measurements_y2025m10 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2025-10-01'::timestamp)*1000) TO (extract ('epoch' from '2025-11-01'::timestamp)*1000);
120
+ CREATE TABLE flow_measurements_y2025m11 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2025-11-01'::timestamp)*1000) TO (extract ('epoch' from '2025-12-01'::timestamp)*1000);
121
+ CREATE TABLE flow_measurements_y2025m12 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2025-12-01'::timestamp)*1000) TO (extract ('epoch' from '2026-01-01'::timestamp)*1000);
122
+ --2026
123
+ CREATE TABLE flow_measurements_y2026m01 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2026-01-01'::timestamp)*1000) TO (extract ('epoch' from '2026-02-01'::timestamp)*1000);
124
+ CREATE TABLE flow_measurements_y2026m02 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2026-02-01'::timestamp)*1000) TO (extract ('epoch' from '2026-03-01'::timestamp)*1000);
125
+ CREATE TABLE flow_measurements_y2026m03 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2026-03-01'::timestamp)*1000) TO (extract ('epoch' from '2026-04-01'::timestamp)*1000);
126
+ CREATE TABLE flow_measurements_y2026m04 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2026-04-01'::timestamp)*1000) TO (extract ('epoch' from '2026-05-01'::timestamp)*1000);
127
+ CREATE TABLE flow_measurements_y2026m05 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2026-05-01'::timestamp)*1000) TO (extract ('epoch' from '2026-06-01'::timestamp)*1000);
128
+ CREATE TABLE flow_measurements_y2026m06 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2026-06-01'::timestamp)*1000) TO (extract ('epoch' from '2026-07-01'::timestamp)*1000);
129
+ CREATE TABLE flow_measurements_y2026m07 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2026-07-01'::timestamp)*1000) TO (extract ('epoch' from '2026-08-01'::timestamp)*1000);
130
+ CREATE TABLE flow_measurements_y2026m08 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2026-08-01'::timestamp)*1000) TO (extract ('epoch' from '2026-09-01'::timestamp)*1000);
131
+ CREATE TABLE flow_measurements_y2026m09 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2026-09-01'::timestamp)*1000) TO (extract ('epoch' from '2026-10-01'::timestamp)*1000);
132
+ CREATE TABLE flow_measurements_y2026m10 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2026-10-01'::timestamp)*1000) TO (extract ('epoch' from '2026-11-01'::timestamp)*1000);
133
+ CREATE TABLE flow_measurements_y2026m11 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2026-11-01'::timestamp)*1000) TO (extract ('epoch' from '2026-12-01'::timestamp)*1000);
134
+ CREATE TABLE flow_measurements_y2026m12 PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2026-12-01'::timestamp)*1000) TO (extract ('epoch' from '2027-01-01'::timestamp)*1000);
135
+ --202
136
+ CREATE TABLE flow_measurements_y2027up PARTITION OF flow_measurements FOR VALUES FROM (extract ('epoch' from '2027-01-01'::timestamp)*1000) TO (maxvalue);
137
+
138
+
139
+ CREATE TABLE flow_od_measurements (
140
+ cube_id int4 NOT NULL,
141
+ analytic_id int4 NOT NULL,
142
+ sequence_number int4 NOT NULL,
143
+ sink_id int4 NOT NULL,
144
+ start_timestamp int8 NOT NULL,
145
+ end_timestamp int8 NOT NULL,
146
+ category varchar(150) NOT NULL,
147
+ origin varchar(150) NOT NULL,
148
+ destination varchar(150) NOT NULL,
149
+ value int4 NOT NULL,
150
+ data_validity varchar(50) NULL,
151
+ create_batch_id int8 NULL,
152
+ created_at timestamptz NULL,
153
+ created_by varchar(150) NULL,
154
+ update_batch_id int8 NULL,
155
+ updated_at timestamptz NULL,
156
+ updated_by varchar(150) NULL,
157
+ CONSTRAINT flow_od_measurementspkey PRIMARY KEY (cube_id, sink_id, start_timestamp, end_timestamp, category, origin, destination, sequence_number)
158
+ );
159
+ CREATE INDEX flow_od_measurements_created_at ON flow_od_measurements USING btree (created_at);
160
+
161
+ CREATE TABLE flow_sinks (
162
+ id int4 NOT NULL,
163
+ "name" varchar(150) NULL,
164
+ history_start_timestamp int8 NOT NULL,
165
+ output_value_type varchar(150) NOT NULL,
166
+ create_batch_id int8 NULL,
167
+ created_at timestamptz NULL,
168
+ created_by varchar(150) NULL,
169
+ update_batch_id int8 NULL,
170
+ updated_at timestamptz NULL,
171
+ updated_by varchar(150) NULL,
172
+ cube_id int4 NOT NULL,
173
+ CONSTRAINT flow_sinkspkey PRIMARY KEY (id, cube_id, output_value_type)
174
+ );
175
+
176
+
177
+ -- Číselníky
178
+
179
+ CREATE TABLE pedestrians_directions_api (
180
+ direction_id varchar(250) NOT NULL,
181
+ cube_id varchar(250) NOT NULL,
182
+ location_id int4 NOT NULL,
183
+ direction_name varchar(50) NOT NULL,
184
+ direction_type varchar(250) NOT NULL
185
+ );
186
+
187
+ INSERT INTO pedestrians_directions_api (direction_id,cube_id,location_id,direction_name,direction_type) VALUES
188
+ ('4','0',1,'Viadukt','1'),
189
+ ('7','0',1,'Výstaviště','2'),
190
+ ('2','1',2,'Můstek','1'),
191
+ ('3','1',2,'Rytířská','2'),
192
+ ('ecoCounter-103061215','ecoCounter-100061215',3,'Pod viadukt','1'),
193
+ ('ecoCounter-104061215','ecoCounter-100061215',3,'Výstaviště','2'),
194
+ ('dir1','wifi1',4,'Holešovice','1'),
195
+ ('dir2','wifi1',4,'Planetarium','2'),
196
+ ('ecoCounter-353245241','ecoCounter-100065230',5,'Planetarium','1'),
197
+ ('ecoCounter-101065230','ecoCounter-100065230',5,'Holešovice','2'),
198
+ ('7','13',6,'Planetarium','1'),
199
+ ('8','13',6,'Holešovice','2'),
200
+ ('5','9',7,'Malá strana','1'),
201
+ ('8','9',7,'Staré město','2'),
202
+ ('6','10',8,'Náplavka, směr centrum','1'),
203
+ ('11','10',8,'Náplavka, směr Vyšehrad','2'),
204
+ ('35','11',9,'Plný profil, směr centrum','1'),
205
+ ('29','11',9,'Plný profil, směr Vyšehrad','2'),
206
+ ('9','10',8,'Rampa, směr centrum','1'),
207
+ ('13','10',8,'Rampa, směr Vyšehrad','2'),
208
+ ('10','10',8,'Plný profil, směr centrum','1'),
209
+ ('15','10',8,'Plný profil, směr Vyšehrad','2');
210
+
211
+ CREATE TABLE pedestrians_locations_api (
212
+ location_id serial4 NOT NULL,
213
+ location_name varchar(250) NULL,
214
+ lat numeric NULL,
215
+ lng numeric NULL,
216
+ address varchar(250) NULL,
217
+ city_district varchar(250) NULL,
218
+ tech varchar(250) NULL,
219
+ map_url varchar(2500) NULL,
220
+ place_url varchar(2500) NULL,
221
+ measurement_start timestamptz NULL,
222
+ measurement_end timestamptz NULL,
223
+ cube_id varchar(250) NULL
224
+ );
225
+
226
+ INSERT INTO pedestrians_locations_api (location_name,lat,lng,address,city_district,tech,map_url,place_url,measurement_start,measurement_end,cube_id) VALUES
227
+ ('Výstaviště - viadukt VO 2',50.1042106575078,14.431679367811926,'U Výstaviště (viadukt)','Praha 7','kamera','https://storage.golemio.cz/intenzita-pesi-dopravy/1.png','https://storage.golemio.cz/intenzita-pesi-dopravy/1-map.png','2020-09-02 00:00:00+02',NULL,'0'),
228
+ ('Rytířská 12',50.084781715549276,14.422412102465428,'Na Můstku 12','Praha 1','kamera','https://storage.golemio.cz/intenzita-pesi-dopravy/2.png','https://storage.golemio.cz/intenzita-pesi-dopravy/2-map.png','2020-09-02 00:00:00+02',NULL,'1'),
229
+ ('Výstaviště - viadukt',50.1042106575078,14.431679367811926,'U Výstaviště (viadukt)','Praha 7','pyro','https://storage.golemio.cz/intenzita-pesi-dopravy/1.png','https://storage.golemio.cz/intenzita-pesi-dopravy/1-map.png','2020-07-23 00:00:00+02','2020-11-10 00:00:00+01','ecoCounter-100061215'),
230
+ ('Stromovka - U Výstaviště',50.10489433551656,14.429609941952332,'U Výstaviště 67','Praha 7','wifi',NULL,'https://storage.golemio.cz/intenzita-pesi-dopravy/4-map.png','2020-11-24 00:00:00+01',NULL,'wifi1'),
231
+ ('Stromovka - U Výstaviště',50.10489433551656,14.429609941952332,'U Výstaviště 67','Praha 7','pyro','https://storage.golemio.cz/intenzita-pesi-dopravy/3.png','https://storage.golemio.cz/intenzita-pesi-dopravy/3-map.png','2020-11-11 00:00:00+01','2021-03-04 00:00:00+01','ecoCounter-100065230'),
232
+ ('Stromovka - U Výstaviště',50.10489433551656,14.429609941952332,'U Výstaviště 67','Praha 7','kamera','https://storage.golemio.cz/intenzita-pesi-dopravy/3.png','https://storage.golemio.cz/intenzita-pesi-dopravy/3-map.png','2020-12-17 00:00:00+01',NULL,'13'),
233
+ ('Staroměstská věž pevná VI',50.08626,14.41301,'Karlův most','Praha 1','kamera','https://storage.golemio.cz/intenzita-pesi-dopravy/5.png','https://storage.golemio.cz/intenzita-pesi-dopravy/5-map.png','2020-09-02 00:00:00+02',NULL,'9'),
234
+ ('Železniční most - náplavka I',50.06739,14.41468,'Novoměstská náplavka','Praha 2','kamera','https://storage.golemio.cz/intenzita-pesi-dopravy/6.png','https://storage.golemio.cz/intenzita-pesi-dopravy/6-map.png','2020-09-02 00:00:00+02',NULL,'10'),
235
+ ('Železniční most - náplavka II',50.06693,14.41480,'Novoměstská náplavka','Praha 2','kamera','https://storage.golemio.cz/intenzita-pesi-dopravy/7.png','https://storage.golemio.cz/intenzita-pesi-dopravy/7-map.png','2020-09-02 00:00:00+02',NULL,'11');
236
+
237
+ -- v_pedestrians_locations_api source
238
+
239
+ CREATE OR REPLACE VIEW v_pedestrians_locations_api
240
+ AS SELECT l.location_id::character varying(5) AS location_id,
241
+ l.location_name,
242
+ l.lat,
243
+ l.lng,
244
+ l.address,
245
+ l.city_district,
246
+ l.tech,
247
+ l.map_url,
248
+ l.place_url,
249
+ l.measurement_start,
250
+ l.measurement_end
251
+ FROM pedestrians_locations_api l
252
+ ORDER BY (l.location_id::character varying(5));
253
+
254
+ -- v_pedestrians_directions_api source
255
+
256
+ CREATE OR REPLACE VIEW v_pedestrians_directions_api
257
+ AS SELECT pedestrians_directions_api.direction_id,
258
+ pedestrians_directions_api.location_id::character varying(5) AS location_id,
259
+ pedestrians_directions_api.direction_name,
260
+ pedestrians_directions_api.direction_type::character varying(5) AS direction_type
261
+ FROM pedestrians_directions_api
262
+ ORDER BY (pedestrians_directions_api.location_id::character varying(5));
263
+
264
+ -- public.counters_detections definition
265
+
266
+ CREATE TABLE counters_detections (
267
+ locations_id varchar(255) NOT NULL,
268
+ directions_id varchar(255) NOT NULL,
269
+ measured_from int8 NOT NULL,
270
+ measured_to int8 NOT NULL,
271
+ category varchar(100) NOT NULL,
272
+ value int4 NULL,
273
+ create_batch_id int8 NULL,
274
+ created_at timestamptz NULL,
275
+ created_by varchar(150) NULL,
276
+ update_batch_id int8 NULL,
277
+ updated_at timestamptz NULL,
278
+ updated_by varchar(150) NULL,
279
+ CONSTRAINT counters_detections_pkey PRIMARY KEY (locations_id, directions_id, measured_from, category)
280
+ );
281
+ CREATE INDEX counters_detections_directions_id ON counters_detections USING btree (directions_id);
282
+ CREATE INDEX counters_detections_locations_id ON counters_detections USING btree (locations_id);
283
+
284
+ -- public.counters_directions definition
285
+
286
+ CREATE TABLE counters_directions (
287
+ id varchar(255) NOT NULL,
288
+ vendor_id varchar(255) NOT NULL,
289
+ locations_id varchar(255) NOT NULL,
290
+ name varchar(255) NULL,
291
+ create_batch_id int8 NULL,
292
+ created_at timestamptz NULL,
293
+ created_by varchar(150) NULL,
294
+ update_batch_id int8 NULL,
295
+ updated_at timestamptz NULL,
296
+ updated_by varchar(150) NULL,
297
+ CONSTRAINT counters_directions_pkey PRIMARY KEY (id)
298
+ );
299
+ CREATE INDEX counters_directions_locations_id ON counters_directions USING btree (locations_id);
300
+
301
+ -- public.counters_locations definition
302
+
303
+ CREATE TABLE counters_locations (
304
+ id varchar(255) NOT NULL,
305
+ vendor_id varchar(255) NOT NULL,
306
+ vendor varchar(100) NULL,
307
+ lat float8 NOT NULL,
308
+ lng float8 NOT NULL,
309
+ name varchar(255) NULL,
310
+ route varchar(255) NULL,
311
+ create_batch_id int8 NULL,
312
+ created_at timestamptz NULL,
313
+ created_by varchar(150) NULL,
314
+ update_batch_id int8 NULL,
315
+ updated_at timestamptz NULL,
316
+ updated_by varchar(150) NULL,
317
+ CONSTRAINT counters_locations_pkey PRIMARY KEY (id)
318
+ );
319
+
320
+ -- pedestrians_wifi definition
321
+
322
+ CREATE TABLE pedestrians_wifi (
323
+ measured_from timestamp NULL,
324
+ start_region varchar(50) NULL,
325
+ end_region varchar(50) NULL,
326
+ value int4 NULL,
327
+ direction_id varchar(50) NULL,
328
+ location_id varchar(50) NULL
329
+ );
330
+
331
+ -- pedestrians_detections_api definition
332
+
333
+ CREATE TABLE pedestrians_detections_api (
334
+ measured_from timestamptz NOT NULL,
335
+ measured_to timestamptz NOT NULL,
336
+ location_id varchar NOT NULL,
337
+ direction_id varchar NOT NULL,
338
+ value int8 NULL,
339
+ quality numeric NULL,
340
+ CONSTRAINT pedestrians_detections_api_pkey PRIMARY KEY (location_id, direction_id, measured_from, measured_to)
341
+ );
342
+
343
+ -- update_detections_data procedure definition
344
+
345
+ CREATE OR replace procedure update_detections_data()
346
+ LANGUAGE plpgsql
347
+ AS $$
348
+ declare
349
+ lastupdatetimestamp timestamptz;
350
+ lastupdateunix bigint;
351
+ begin
352
+ select
353
+ case
354
+ when flowmax.max_measured_from is not null
355
+ then flowmax.max_measured_from
356
+ else to_timestamp(0)
357
+ end as max_measured_from into lastupdatetimestamp
358
+ from (select max(measured_from) - interval '1 hours' as max_measured_from from flow.pedestrians_detections_api) flowMax;
359
+
360
+ lastupdateunix := extract ('epoch' from lastupdatetimestamp) * 1000;
361
+
362
+
363
+ insert into flow.pedestrians_detections_api
364
+ with wifi as (
365
+ select
366
+ pedestrians_wifi.location_id,
367
+ pedestrians_wifi.direction_id,
368
+ date_trunc('hour'::text, pedestrians_wifi.measured_from) + (date_part('minute'::text, pedestrians_wifi.measured_from)::integer / 15)::double precision * '00:15:00'::interval as measured_from,
369
+ date_trunc('hour'::text, pedestrians_wifi.measured_from) + (date_part('minute'::text, pedestrians_wifi.measured_from)::integer / 15)::double precision * '00:15:00'::interval + '00:15:00'::interval as measured_to,
370
+ sum(pedestrians_wifi.value) as value,
371
+ count(pedestrians_wifi.value) as count_n,
372
+ 3 as quantity
373
+ from
374
+ flow.pedestrians_wifi
375
+ group by
376
+ pedestrians_wifi.location_id,
377
+ pedestrians_wifi.direction_id,
378
+ (date_trunc('hour'::text, pedestrians_wifi.measured_from) + (date_part('minute'::text, pedestrians_wifi.measured_from)::integer / 15)::double precision * '00:15:00'::interval),
379
+ (date_trunc('hour'::text, pedestrians_wifi.measured_from) + (date_part('minute'::text, pedestrians_wifi.measured_from)::integer / 15)::double precision * '00:15:00'::interval + '00:15:00'::interval)
380
+ ) SELECT wifi.measured_from,
381
+ wifi.measured_to,
382
+ wifi.location_id,
383
+ wifi.direction_id,
384
+ wifi.value,
385
+ wifi.count_n::numeric / wifi.quantity::numeric AS quality
386
+ FROM wifi
387
+ where wifi.measured_from > lastupdatetimestamp
388
+ ON CONFLICT (location_id,direction_id,measured_from,measured_to)
389
+ DO update
390
+ SET value = EXCLUDED.value,
391
+ quality = EXCLUDED.quality;
392
+
393
+ insert into flow.pedestrians_detections_api
394
+ with pyro as (
395
+ select
396
+ cd.locations_id as location_id,
397
+ cd.directions_id as direction_id,
398
+ to_timestamp((cd.measured_from / 1000)::double precision) as measured_from,
399
+ to_timestamp((cd.measured_from / 1000)::double precision) + '00:15:00'::interval as measured_to,
400
+ sum(cd.value) as value,
401
+ 1 as count_n,
402
+ 1 as quantity
403
+ from flow.counters_detections cd
404
+ where
405
+ cd.category::text = 'pedestrian'::text
406
+ and (cd.directions_id::text in (select distinct pedestrians_directions_api.direction_id from flow.pedestrians_directions_api))
407
+ group by
408
+ cd.locations_id,
409
+ cd.directions_id,
410
+ (to_timestamp((cd.measured_from / 1000)::double precision)),
411
+ (to_timestamp((cd.measured_from / 1000)::double precision) + '00:15:00'::interval)
412
+ )
413
+ select
414
+ pyro.measured_from,
415
+ pyro.measured_to,
416
+ pyro.location_id,
417
+ pyro.direction_id,
418
+ pyro.value,
419
+ pyro.count_n::numeric / pyro.quantity::numeric as quality
420
+ from pyro
421
+ where pyro.measured_from > lastupdatetimestamp
422
+ ON CONFLICT (location_id,direction_id,measured_from,measured_to)
423
+ DO update
424
+ SET value = EXCLUDED.value,
425
+ quality = EXCLUDED.quality;
426
+
427
+
428
+ insert into flow.pedestrians_detections_api
429
+ with vyber as (
430
+ select * from flow.flow_measurements where flow_measurements.start_timestamp > lastupdateunix and category::text = 'pedestrian'::text
431
+ ), flow as (
432
+ select
433
+ vyber.cube_id::character varying(50) as location_id,
434
+ vyber.sink_id::character varying(50) as direction_id,
435
+ date_trunc('hour'::text, to_timestamp((vyber.start_timestamp / 1000)::double precision)) + (date_part('minute'::text, to_timestamp((vyber.start_timestamp / 1000)::double precision))::integer / 15)::double precision * '00:15:00'::interval as measured_from,
436
+ date_trunc('hour'::text, to_timestamp((vyber.start_timestamp / 1000)::double precision)) + (date_part('minute'::text, to_timestamp((vyber.start_timestamp / 1000)::double precision))::integer / 15)::double precision * '00:15:00'::interval + '00:15:00'::interval as measured_to,
437
+ sum(vyber.value) as value,
438
+ count(vyber.value) as count_n,
439
+ 3 as quantity
440
+ from
441
+ vyber
442
+ where
443
+ ((vyber.cube_id::character varying(50)::text,
444
+ vyber.sink_id::character varying(50)::text) in (
445
+ select distinct
446
+ pedestrians_directions_api.cube_id as location_id,
447
+ pedestrians_directions_api.direction_id
448
+ from
449
+ flow.pedestrians_directions_api))
450
+ group by 1,2,3,4
451
+ ) select
452
+ flow.measured_from,
453
+ flow.measured_to,
454
+ flow.location_id,
455
+ flow.direction_id,
456
+ flow.value,
457
+ flow.count_n::numeric / flow.quantity::numeric as quality
458
+ from flow
459
+ where flow.measured_from > lastupdatetimestamp
460
+ ON CONFLICT (location_id,direction_id,measured_from,measured_to)
461
+ DO update
462
+ SET value = EXCLUDED.value,
463
+ quality = EXCLUDED.quality;
464
+ end;
465
+ $$;
466
+
467
+ -- ^^
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,14 @@
1
+ import { BaseWorker } from "@golemio/core/dist/integration-engine/workers";
2
+ export declare class CountersWorker extends BaseWorker {
3
+ private dataSourceEcoCounter;
4
+ private dataSourceEcoCounterMeasurements;
5
+ private ecoCounterTransformation;
6
+ private ecoCounterMeasurementsTransformation;
7
+ private queuePrefix;
8
+ private countersLocationsModel;
9
+ private countersDirectionsModel;
10
+ private countersDetectionsModel;
11
+ constructor();
12
+ refreshEcoCounterDataInDB: (msg: any) => Promise<void>;
13
+ updateEcoCounter: (msg: any) => Promise<void>;
14
+ }
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.CountersWorker = void 0;
16
+ const index_1 = require("../schema-definitions/index");
17
+ const config_1 = require("@golemio/core/dist/integration-engine/config");
18
+ const datasources_1 = require("@golemio/core/dist/integration-engine/datasources");
19
+ const models_1 = require("@golemio/core/dist/integration-engine/models");
20
+ const workers_1 = require("@golemio/core/dist/integration-engine/workers");
21
+ const golemio_validator_1 = require("@golemio/core/dist/shared/golemio-validator");
22
+ const moment_timezone_1 = __importDefault(require("@golemio/core/dist/shared/moment-timezone"));
23
+ const EcoCounterMeasurementsTransformation_1 = require("./transformations/EcoCounterMeasurementsTransformation");
24
+ const EcoCounterTransformation_1 = require("./transformations/EcoCounterTransformation");
25
+ class CountersWorker extends workers_1.BaseWorker {
26
+ constructor() {
27
+ super();
28
+ this.refreshEcoCounterDataInDB = (msg) => __awaiter(this, void 0, void 0, function* () {
29
+ const data = yield this.dataSourceEcoCounter.getAll();
30
+ const transformedData = yield this.ecoCounterTransformation.transform(data);
31
+ yield this.countersLocationsModel.save(transformedData.locationsPedestrians);
32
+ yield this.countersDirectionsModel.save(transformedData.directionsPedestrians);
33
+ const promisesPeds = transformedData.directionsPedestrians.map((p) => {
34
+ this.sendMessageToExchange("workers." + this.queuePrefix + ".updateEcoCounter", JSON.stringify({
35
+ category: "pedestrian",
36
+ directions_id: p.id,
37
+ id: p.vendor_id,
38
+ locations_id: p.locations_id,
39
+ }));
40
+ });
41
+ yield Promise.all(promisesPeds);
42
+ });
43
+ this.updateEcoCounter = (msg) => __awaiter(this, void 0, void 0, function* () {
44
+ const inputData = JSON.parse(msg.content.toString());
45
+ const locationsId = inputData.locations_id;
46
+ const directionsId = inputData.directions_id;
47
+ const category = inputData.category;
48
+ const id = inputData.id;
49
+ // EcoCounter API is actually working with local Europe/Prague time, not ISO!!!
50
+ // so we have to send local time to request.
51
+ // Furthermore, the returned dates are START of the measurement interval, so if we want measurements
52
+ // from interval between 06:00 and 07:00 UTC (which is local 07:00 - 08:00), we have to send parameters
53
+ // from=07:00 and to=07:45, because it returns all the measurements where from and to parameters are INCLUDED.
54
+ const now = moment_timezone_1.default.utc().tz("Europe/Prague");
55
+ const step = 15;
56
+ const remainder = now.minute() % step;
57
+ // rounded to nearest next 15 minutes
58
+ const nowRounded = now.clone().subtract(remainder, "minutes").seconds(0).milliseconds(0);
59
+ const strTo = nowRounded.clone().subtract(step, "minutes").format("YYYY-MM-DDTHH:mm:ss");
60
+ const strFrom = nowRounded.clone().subtract(72, "hours").format("YYYY-MM-DDTHH:mm:ss");
61
+ let url = config_1.config.datasources.BicycleCountersEcoCounterMeasurements;
62
+ url = url.replace(":id", id);
63
+ url = url.replace(":from", strFrom);
64
+ url = url.replace(":to", strTo);
65
+ url = url.replace(":step", `${step}m`);
66
+ url = url.replace(":complete", "true");
67
+ this.dataSourceEcoCounterMeasurements.setProtocolStrategy(new datasources_1.HTTPProtocolStrategy({
68
+ headers: {
69
+ Authorization: `Bearer ${config_1.config.datasources.CountersEcoCounterTokens.OICT}`,
70
+ },
71
+ json: true,
72
+ method: "GET",
73
+ url,
74
+ }));
75
+ const data = yield this.dataSourceEcoCounterMeasurements.getAll();
76
+ // pedestrians
77
+ if (category === "pedestrian") {
78
+ yield this.countersDetectionsModel.saveBySqlFunction((yield this.ecoCounterMeasurementsTransformation.transform(data)).map((x) => {
79
+ x.directions_id = directionsId;
80
+ x.locations_id = locationsId;
81
+ x.category = "pedestrian";
82
+ return x;
83
+ }), ["locations_id", "directions_id", "measured_from", "category"]);
84
+ }
85
+ });
86
+ const parser = new datasources_1.JSONDataTypeStrategy({ resultsPath: "" });
87
+ parser.setFilter((item) => item.counter !== null);
88
+ this.dataSourceEcoCounter = new datasources_1.DataSource(index_1.Counters.ecoCounter.name + "DataSource", new datasources_1.HTTPProtocolStrategy({
89
+ headers: {
90
+ Authorization: `Bearer ${config_1.config.datasources.CountersEcoCounterTokens.OICT}`,
91
+ },
92
+ method: "GET",
93
+ url: config_1.config.datasources.BicycleCountersEcoCounter,
94
+ }), parser, new golemio_validator_1.JSONSchemaValidator(index_1.Counters.ecoCounter.name + "Validator", index_1.Counters.ecoCounter.datasourceJsonSchema));
95
+ this.dataSourceEcoCounterMeasurements = new datasources_1.DataSource(index_1.Counters.ecoCounter.name + "MeasurementsDataSource", undefined, new datasources_1.JSONDataTypeStrategy({ resultsPath: "" }), new golemio_validator_1.JSONSchemaValidator(index_1.Counters.ecoCounter.name + "MeasurementsDataSource", index_1.Counters.ecoCounter.measurementsDatasourceJsonSchema));
96
+ this.ecoCounterTransformation = new EcoCounterTransformation_1.EcoCounterTransformation();
97
+ this.ecoCounterMeasurementsTransformation = new EcoCounterMeasurementsTransformation_1.EcoCounterMeasurementsTransformation();
98
+ this.countersLocationsModel = new models_1.PostgresModel(index_1.Counters.locations.name + "Model", {
99
+ outputSequelizeAttributes: index_1.Counters.locations.outputSequelizeAttributes,
100
+ pgTableName: index_1.Counters.locations.pgTableName,
101
+ pgSchema: index_1.Counters.pgSchema,
102
+ savingType: "insertOrUpdate",
103
+ }, new golemio_validator_1.JSONSchemaValidator(index_1.Counters.locations.name + "ModelValidator", index_1.Counters.locations.outputJsonSchemaObject));
104
+ this.countersDirectionsModel = new models_1.PostgresModel(index_1.Counters.directions.name + "Model", {
105
+ outputSequelizeAttributes: index_1.Counters.directions.outputSequelizeAttributes,
106
+ pgTableName: index_1.Counters.directions.pgTableName,
107
+ pgSchema: index_1.Counters.pgSchema,
108
+ savingType: "insertOrUpdate",
109
+ }, new golemio_validator_1.JSONSchemaValidator(index_1.Counters.directions.name + "ModelValidator", index_1.Counters.directions.outputJsonSchemaObject));
110
+ this.countersDetectionsModel = new models_1.PostgresModel(index_1.Counters.detections.name + "Model", {
111
+ outputSequelizeAttributes: index_1.Counters.detections.outputSequelizeAttributes,
112
+ pgTableName: index_1.Counters.detections.pgTableName,
113
+ pgSchema: index_1.Counters.pgSchema,
114
+ savingType: "insertOrUpdate",
115
+ }, new golemio_validator_1.JSONSchemaValidator(index_1.Counters.detections.name + "ModelValidator", index_1.Counters.detections.outputJsonSchemaObject));
116
+ this.queuePrefix = config_1.config.RABBIT_EXCHANGE_NAME + "." + "counters";
117
+ }
118
+ }
119
+ exports.CountersWorker = CountersWorker;
120
+ //# sourceMappingURL=CountersWorker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CountersWorker.js","sourceRoot":"","sources":["../../src/integration-engine/CountersWorker.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uDAAsC;AACtC,yEAAsE;AACtE,mFAA2H;AAC3H,yEAA6E;AAC7E,2EAA2E;AAC3E,mFAAkF;AAClF,gGAA+D;AAC/D,iHAA8G;AAC9G,yFAAsF;AAEtF,MAAa,cAAe,SAAQ,oBAAU;IAa1C;QACI,KAAK,EAAE,CAAC;QA8DL,8BAAyB,GAAG,CAAO,GAAQ,EAAiB,EAAE;YACjE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE,CAA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