@golemio/microclimate 1.1.3 → 1.1.4

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 (55) hide show
  1. package/db/example/00_truncate_tables.sql +2 -2
  2. package/db/example/01_microclimate.sql +44 -2
  3. package/db/migrations/postgresql/20230215185618-og-api.js +53 -0
  4. package/db/migrations/postgresql/sqls/20230215185618-og-api-down.sql +5 -0
  5. package/db/migrations/postgresql/sqls/20230215185618-og-api-up.sql +172 -0
  6. package/dist/integration-engine/schema/RefreshMeasurementsByIdTaskSchema.js.map +1 -1
  7. package/dist/output-gateway/MicroclimateRouter.d.ts +4 -0
  8. package/dist/output-gateway/MicroclimateRouter.js +85 -0
  9. package/dist/output-gateway/MicroclimateRouter.js.map +1 -0
  10. package/dist/output-gateway/helpers/LocationsOutputMapper.d.ts +18 -0
  11. package/dist/output-gateway/helpers/LocationsOutputMapper.js +35 -0
  12. package/dist/output-gateway/helpers/LocationsOutputMapper.js.map +1 -0
  13. package/dist/output-gateway/helpers/PointsOutputMapper.d.ts +27 -0
  14. package/dist/output-gateway/helpers/PointsOutputMapper.js +45 -0
  15. package/dist/output-gateway/helpers/PointsOutputMapper.js.map +1 -0
  16. package/dist/output-gateway/index.d.ts +1 -0
  17. package/dist/output-gateway/index.js +18 -0
  18. package/dist/output-gateway/index.js.map +1 -0
  19. package/dist/output-gateway/repositories/SensorDevicesImportRepository.d.ts +19 -0
  20. package/dist/output-gateway/repositories/SensorDevicesImportRepository.js +55 -0
  21. package/dist/output-gateway/repositories/SensorDevicesImportRepository.js.map +1 -0
  22. package/dist/output-gateway/repositories/SensorMeasurementsViewRepository.d.ts +16 -0
  23. package/dist/output-gateway/repositories/SensorMeasurementsViewRepository.js +53 -0
  24. package/dist/output-gateway/repositories/SensorMeasurementsViewRepository.js.map +1 -0
  25. package/dist/output-gateway/repositories/SensorPointsViewRepository.d.ts +11 -0
  26. package/dist/output-gateway/repositories/SensorPointsViewRepository.js +43 -0
  27. package/dist/output-gateway/repositories/SensorPointsViewRepository.js.map +1 -0
  28. package/dist/output-gateway/repositories/index.d.ts +3 -0
  29. package/dist/output-gateway/repositories/index.js +20 -0
  30. package/dist/output-gateway/repositories/index.js.map +1 -0
  31. package/dist/schema-definitions/SensorDevicesImport.d.ts +33 -0
  32. package/dist/schema-definitions/SensorDevicesImport.js +8 -0
  33. package/dist/schema-definitions/SensorDevicesImport.js.map +1 -0
  34. package/dist/schema-definitions/SensorMeasurementsView.d.ts +14 -0
  35. package/dist/schema-definitions/SensorMeasurementsView.js +8 -0
  36. package/dist/schema-definitions/SensorMeasurementsView.js.map +1 -0
  37. package/dist/schema-definitions/SensorPointsView.d.ts +23 -0
  38. package/dist/schema-definitions/SensorPointsView.js +8 -0
  39. package/dist/schema-definitions/SensorPointsView.js.map +1 -0
  40. package/dist/schema-definitions/datasources/MeasurementsJsonSchema.d.ts +0 -3
  41. package/dist/schema-definitions/datasources/MeasurementsJsonSchema.js.map +1 -1
  42. package/dist/schema-definitions/index.js +6 -0
  43. package/dist/schema-definitions/index.js.map +1 -1
  44. package/dist/schema-definitions/models/SensorDevicesImportModel.d.ts +32 -0
  45. package/dist/schema-definitions/models/SensorDevicesImportModel.js +37 -0
  46. package/dist/schema-definitions/models/SensorDevicesImportModel.js.map +1 -0
  47. package/dist/schema-definitions/models/SensorMeasurementsViewModel.d.ts +13 -0
  48. package/dist/schema-definitions/models/SensorMeasurementsViewModel.js +18 -0
  49. package/dist/schema-definitions/models/SensorMeasurementsViewModel.js.map +1 -0
  50. package/dist/schema-definitions/models/SensorPointsViewModel.d.ts +22 -0
  51. package/dist/schema-definitions/models/SensorPointsViewModel.js +27 -0
  52. package/dist/schema-definitions/models/SensorPointsViewModel.js.map +1 -0
  53. package/docs/implementation_documentation.md +20 -1
  54. package/docs/openapi.yaml +298 -0
  55. package/package.json +2 -2
@@ -1,2 +1,2 @@
1
- -- TRUNCATE "sensor_devices";
2
- -- TRUNCATE "measurements";
1
+ TRUNCATE "sensor_devices_import";
2
+ TRUNCATE "measurements";
@@ -1,2 +1,44 @@
1
- -- INSERT INTO sensor_devices ...
2
- -- INSERT INTO measurements ...
1
+ INSERT INTO sensor_devices_import (location_id, point_id, location, loc_description, loc_orientation, loc_surface, point_name, point_whole_name, address, sensor_position, sensor_position_detail, sensor_id, data_relevance, lat, lng, air_temp, air_hum, pressure, wind_dir, wind_impact, wind_speed, precip, sun_irr, soil_temp, water_pot, dendro_circ, dendro_gain) VALUES
2
+ (130, 131, 'Pražská Holešovická tržnice', 'areál bez zeleně', 'východ-západ', 'asfalt/beton', 'Pražská tržnice osvětlení', 'Tržnice | sloup VO | 0,5m | #063', 'Pražská tržnice', 'veřejné osvětlení', 'veřejné osvětlení ve středu Tržnice', '323434316F317A18', '2022-08-11', 50.098934, 14.445023, 50, 50, 50, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
3
+ (130, 131, 'Pražská Holešovická tržnice', 'areál bez zeleně', 'východ-západ', 'asfalt/beton', 'Pražská tržnice osvětlení', 'Tržnice | sloup VO | 2m | #0190', 'Pražská tržnice', 'veřejné osvětlení', 'veřejné osvětlení ve středu Tržnice', '323434317F317F18', '2022-08-11', 50.098934, 14.445023, 200, 200, 200, 300, 300, 300, 300, 200, NULL, NULL, NULL, NULL),
4
+ (130, 132, 'Pražská Holešovická tržnice', 'areál bez zeleně', 'východ-západ', 'asfalt/beton', 'Pražská tržnice jižní strom', 'Tržnice | jižní strom | -0,3cm | #046', 'Pražská tržnice', 'strom', 'jižní strom', '323434316A317519', '2022-08-11', 50.098816, 14.445016, 50, 50, 50, NULL, NULL, NULL, NULL, NULL, -30, -30, 200, 200),
5
+ (130, 132, 'Pražská Holešovická tržnice', 'areál bez zeleně', 'východ-západ', 'asfalt/beton', 'Pražská tržnice jižní strom', 'Tržnice | jižní strom | -0,1cm | #080', 'Pražská tržnice', 'strom', 'jižní strom', '3234343178318318', '2022-08-11', 50.098816, 14.445016, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -10, -10, NULL, NULL),
6
+ (130, 133, 'Pražská Holešovická tržnice', 'areál bez zeleně', 'východ-západ', 'asfalt/beton', 'Pražská tržnice severní strom', 'Tržnice | severní strom | -0,3cm | #097', 'Pražská tržnice', 'strom', 'severní strom', '3234343177317318', '2022-08-11', 50.099163, 14.444832, 50, 50, 50, NULL, NULL, NULL, NULL, NULL, -30, -30, 200, 200),
7
+ (130, 133, 'Pražská Holešovická tržnice', 'areál bez zeleně', 'východ-západ', 'asfalt/beton', 'Pražská tržnice severní strom', 'Tržnice | severní strom | -0,1cm | #0102', 'Pražská tržnice', 'strom', 'severní strom', '3234343176317918', '2022-08-11', 50.099163, 14.444832, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -10, -10, NULL, NULL);
8
+
9
+ INSERT INTO measurements (sensor_id, measurement_id, measured_at, air_temp, air_hum, pressure, wind_dir, wind_speed, wind_impact, precip, sun_irr, dendro_circ, dendro_gain, water_pot, soil_temp) VALUES
10
+ ('323434316F317A18', '63edfacd96553b2cde597624', '2023-02-16 10:43:41.682+01', 4, 73.4, 100470, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
11
+ ('3234343177317318', '63edfba096553b2cde59774d', '2023-02-16 10:47:12.006+01', 4.9, 67, 100470, NULL, NULL, NULL, NULL, NULL, 988.662532552085, -1.33746744791533, -9.039, 3.2),
12
+ ('3234343178318318', '63edfb0d96553b2cde597674', '2023-02-16 10:44:45.053+01', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -9.8572, 0.5),
13
+ ('3234343176317918', '63edfb1796553b2cde597688', '2023-02-16 10:44:55.455+01', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -4.62828, 2.7),
14
+ ('323434317F317F18', '63edfc1c96553b2cde5977fe', '2023-02-16 10:49:15.914+01', 2.2, 78.5, 100470, 'N', 1.42795716128516, 7.2405, 0, 11382, NULL, NULL, NULL, NULL),
15
+ ('323434316A317519', '63edfc1696553b2cde5977f4', '2023-02-16 10:49:10.307+01', 1.9, 77.2, 100470, NULL, NULL, NULL, NULL, NULL, 548.06648763021, -1.93351236978973, -13.013, 2.7),
16
+ ('323434316F317A18', '63edfd2596553b2cde597975', '2023-02-16 10:53:41.695+01', 2.8, 77.4, 100480, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
17
+ ('3234343176317918', '63edfd6f96553b2cde5979e8', '2023-02-16 10:54:55.462+01', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -4.62828, 2.8),
18
+ ('3234343178318318', '63edfd6596553b2cde5979d2', '2023-02-16 10:54:45.064+01', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -9.8572, 0.5),
19
+ ('323434316A317519', '63edfe6e96553b2cde597b49', '2023-02-16 10:59:10.325+01', 2.2, 76.4, 100460, NULL, NULL, NULL, NULL, NULL, 548.077473958335, -1.92252604166475, -13.013, 2.7),
20
+ ('323434317F317F18', '63edfe7496553b2cde597b53', '2023-02-16 10:59:15.92+01', 2.5, 77.6, 100460, 'N', 2.1519784802152, 6.51645, 0, 11127, NULL, NULL, NULL, NULL),
21
+ ('3234343178318318', '63edf1ad96553b2cde5968e5', '2023-02-16 10:04:44.999+01', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -9.8572, 0.5),
22
+ ('3234343176317918', '63edf1b796553b2cde5968f1', '2023-02-16 10:04:55.417+01', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -4.62828, 2.3),
23
+ ('323434316F317A18', '63edf16d96553b2cde596883', '2023-02-16 10:03:41.636+01', 2.3, 80.8, 100480, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
24
+ ('323434317F317F18', '63edf2bc96553b2cde596a5f', '2023-02-16 10:09:15.875+01', 1.9, 80.1, 100470, 'E', 0.983975400614985, 5.06835, 0, 10383, NULL, NULL, NULL, NULL),
25
+ ('323434316A317519', '63edf2b696553b2cde596a5b', '2023-02-16 10:09:10.267+01', 0.7, 82.7, 100470, NULL, NULL, NULL, NULL, NULL, 548.062825520835, -1.93717447916473, -13.013, 2.7),
26
+ ('3234343177317318', '63edf24096553b2cde5969b8', '2023-02-16 10:07:11.976+01', 2.5, 76.7, 100480, NULL, NULL, NULL, NULL, NULL, 988.625911458335, -1.37408854166529, -9.94292, 3.2),
27
+ ('323434316F317A18', '63edf3c596553b2cde596be1', '2023-02-16 10:13:41.643+01', 1.9, 81.9, 100490, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
28
+ ('3234343176317918', '63edf40f96553b2cde596c4b', '2023-02-16 10:14:55.484+01', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -4.54256, 2.4),
29
+ ('3234343178318318', '63edf40596553b2cde596c36', '2023-02-16 10:14:45.016+01', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -9.8572, 0.5),
30
+ ('3234343177317318', '63edf49896553b2cde596d18', '2023-02-16 10:17:11.979+01', 2.7, 73.9, 100480, NULL, NULL, NULL, NULL, NULL, 988.62224934896, -1.37775065104029, -10.02864, 3.2),
31
+ ('323434316A317519', '63edf50e96553b2cde596dca', '2023-02-16 10:19:10.267+01', 1, 81.4, 100470, NULL, NULL, NULL, NULL, NULL, 548.062825520835, -1.93717447916473, -13.013, 2.7),
32
+ ('323434317F317F18', '63edf51496553b2cde596dd0', '2023-02-16 10:19:15.882+01', 1.4, 82.1, 100470, 'S', 1.30798474017803, 4.3443, 0, 10680, NULL, NULL, NULL, NULL),
33
+ ('3234343177317318', '63edf6f096553b2cde597098', '2023-02-16 10:27:11.99+01', 2.4, 76, 100480, NULL, NULL, NULL, NULL, NULL, 988.625911458335, -1.37408854166529, -10.11436, 3.2),
34
+ ('323434316F317A18', '63edf61d96553b2cde596f57', '2023-02-16 10:23:41.655+01', 2.3, 81.1, 100480, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
35
+ ('3234343178318318', '63edf65d96553b2cde596fb4', '2023-02-16 10:24:45.037+01', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -9.8572, 0.5),
36
+ ('3234343176317918', '63edf66796553b2cde596fcb', '2023-02-16 10:24:55.442+01', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -4.714, 2.4),
37
+ ('323434317F317F18', '63edf76c96553b2cde597134', '2023-02-16 10:29:15.889+01', 2.1, 80.2, 100470, 'SE', 1.20798590683109, 4.3443, 0, 11099, NULL, NULL, NULL, NULL),
38
+ ('323434316A317519', '63edf76696553b2cde59712d', '2023-02-16 10:29:10.286+01', 1.3, 80.5, 100470, NULL, NULL, NULL, NULL, NULL, 548.06648763021, -1.93351236978973, -13.013, 2.7),
39
+ ('3234343176317918', '63edf8bf96553b2cde597326', '2023-02-16 10:34:55.45+01', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -4.62828, 2.5),
40
+ ('3234343178318318', '63edf8b596553b2cde597318', '2023-02-16 10:34:45.036+01', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -9.8572, 0.5),
41
+ ('323434316F317A18', '63edf87596553b2cde5972b6', '2023-02-16 10:33:41.668+01', 2.8, 79.3, 100470, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
42
+ ('323434316A317519', '63edf9be96553b2cde597491', '2023-02-16 10:39:10.302+01', 1.7, 79.2, 100470, NULL, NULL, NULL, NULL, NULL, 548.06648763021, -1.93351236978973, -13.013, 2.7),
43
+ ('323434317F317F18', '63edf9c496553b2cde597499', '2023-02-16 10:39:15.896+01', 3.2, 76.3, 100460, 'N', 0.487994306733088, 2.17215, 0, 11286, NULL, NULL, NULL, NULL),
44
+ ('3234343177317318', '63edf94896553b2cde5973ee', '2023-02-16 10:37:11.994+01', 3.9, 71.5, 100470, NULL, NULL, NULL, NULL, NULL, 988.63689778646, -1.3631022135403, -10.11436, 3.2);
@@ -0,0 +1,53 @@
1
+ 'use strict';
2
+
3
+ var dbm;
4
+ var type;
5
+ var seed;
6
+ var fs = require('fs');
7
+ var path = require('path');
8
+ var Promise;
9
+
10
+ /**
11
+ * We receive the dbmigrate dependency from dbmigrate initially.
12
+ * This enables us to not have to rely on NODE_PATH.
13
+ */
14
+ exports.setup = function(options, seedLink) {
15
+ dbm = options.dbmigrate;
16
+ type = dbm.dataType;
17
+ seed = seedLink;
18
+ Promise = options.Promise;
19
+ };
20
+
21
+ exports.up = function(db) {
22
+ var filePath = path.join(__dirname, 'sqls', '20230215185618-og-api-up.sql');
23
+ return new Promise( function( resolve, reject ) {
24
+ fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
25
+ if (err) return reject(err);
26
+ console.log('received data: ' + data);
27
+
28
+ resolve(data);
29
+ });
30
+ })
31
+ .then(function(data) {
32
+ return db.runSql(data);
33
+ });
34
+ };
35
+
36
+ exports.down = function(db) {
37
+ var filePath = path.join(__dirname, 'sqls', '20230215185618-og-api-down.sql');
38
+ return new Promise( function( resolve, reject ) {
39
+ fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
40
+ if (err) return reject(err);
41
+ console.log('received data: ' + data);
42
+
43
+ resolve(data);
44
+ });
45
+ })
46
+ .then(function(data) {
47
+ return db.runSql(data);
48
+ });
49
+ };
50
+
51
+ exports._meta = {
52
+ "version": 1
53
+ };
@@ -0,0 +1,5 @@
1
+ DROP VIEW IF EXISTS v_sensor_points;
2
+ DROP VIEW IF EXISTS v_sensor_measurements;
3
+
4
+ DROP INDEX measured_at_idx;
5
+ DROP INDEX sensor_id_idx;
@@ -0,0 +1,172 @@
1
+ /**
2
+ v_sensor_points view for output api
3
+ **/
4
+ CREATE OR REPLACE VIEW v_sensor_points AS
5
+ SELECT DISTINCT
6
+ s.point_id,
7
+ s.point_name,
8
+ s.location_id,
9
+ s.location,
10
+ s.loc_description,
11
+ s.loc_orientation,
12
+ s.loc_surface,
13
+ s.lat,
14
+ s.lng,
15
+ null AS x_jtsk, -- bude doplneno na s.x_jtsk
16
+ null AS y_jtsk, -- bude doplneno
17
+ null AS elevation_m, -- bude doplneno
18
+ s.sensor_position,
19
+ s.sensor_position_detail,
20
+ CONCAT(unpivot.measure, unpivot.height_cm) AS measure,
21
+ CASE
22
+ WHEN unpivot.measure = 'air_temp' THEN 'Teplota vzduchu'
23
+ WHEN unpivot.measure = 'air_hum' THEN 'Vlhkost vzduchu'
24
+ WHEN unpivot.measure = 'pressure' THEN 'Atmosférický tlak'
25
+ WHEN unpivot.measure = 'wind_dir' THEN 'Směr větru'
26
+ WHEN unpivot.measure = 'wind_impact' THEN 'Náraz větru'
27
+ WHEN unpivot.measure = 'wind_speed' THEN 'Rychlost větru'
28
+ WHEN unpivot.measure = 'precip' THEN 'Úhrn srážek'
29
+ WHEN unpivot.measure = 'sun_irr' THEN 'Sluneční záření'
30
+ WHEN unpivot.measure = 'soil_temp' THEN 'Teplota půdy'
31
+ WHEN unpivot.measure = 'water_pot' THEN 'Vodní potenciál půdy'
32
+ WHEN unpivot.measure = 'dendro_circ' THEN 'Obvod stromu'
33
+ WHEN unpivot.measure = 'dendro_gain' THEN 'Přírůstek obvodu stromu'
34
+ ELSE NULL
35
+ END AS measure_cz,
36
+ CASE
37
+ WHEN unpivot.measure = 'air_temp' THEN '°C'
38
+ WHEN unpivot.measure = 'air_hum' THEN '%'
39
+ WHEN unpivot.measure = 'pressure' THEN 'Pa'
40
+ WHEN unpivot.measure = 'wind_dir' THEN '°'
41
+ WHEN unpivot.measure = 'wind_impact' THEN 'km/h'
42
+ WHEN unpivot.measure = 'wind_speed' THEN 'km/h'
43
+ WHEN unpivot.measure = 'precip' THEN 'mm'
44
+ WHEN unpivot.measure = 'sun_irr' THEN 'lux'
45
+ WHEN unpivot.measure = 'soil_temp' THEN '°C'
46
+ WHEN unpivot.measure = 'water_pot' THEN 'kPa'
47
+ WHEN unpivot.measure = 'dendro_circ' THEN 'mm'
48
+ WHEN unpivot.measure = 'dendro_gain' THEN 'µm'
49
+ ELSE NULL
50
+ END AS unit
51
+ FROM
52
+ sensor_devices_import s,
53
+ LATERAL (
54
+ VALUES ('air_temp',s.air_temp),
55
+ ('air_hum',s.air_hum),
56
+ ('pressure',s.pressure),
57
+ ('wind_dir',s.wind_dir),
58
+ ('wind_impact',s.wind_impact),
59
+ ('wind_speed',s.wind_speed),
60
+ ('precip',s.precip),
61
+ ('sun_irr',s.sun_irr),
62
+ ('soil_temp',s.soil_temp),
63
+ ('water_pot',s.water_pot),
64
+ ('dendro_circ',s.dendro_circ),
65
+ ('dendro_gain',s.dendro_gain)
66
+ )
67
+ unpivot(measure, height_cm)
68
+ WHERE height_cm is not null
69
+ ORDER BY point_id ASC;
70
+
71
+
72
+ /**
73
+ v_sensor_measurements view for output api
74
+ **/
75
+ CREATE OR REPLACE VIEW v_sensor_measurements AS
76
+ WITH points_heights AS (
77
+ SELECT
78
+ s.sensor_id,
79
+ s.point_id,
80
+ s.location_id,
81
+ unpivot.measure,
82
+ unpivot.height_cm,
83
+ CASE
84
+ WHEN unpivot.measure = 'air_temp' THEN '°C'
85
+ WHEN unpivot.measure = 'air_hum' THEN '%'
86
+ WHEN unpivot.measure = 'pressure' THEN 'Pa'
87
+ WHEN unpivot.measure = 'wind_dir' THEN '°'
88
+ WHEN unpivot.measure = 'wind_impact' THEN 'km/h'
89
+ WHEN unpivot.measure = 'wind_speed' THEN 'km/h'
90
+ WHEN unpivot.measure = 'precip' THEN 'mm'
91
+ WHEN unpivot.measure = 'sun_irr' THEN 'lux'
92
+ WHEN unpivot.measure = 'soil_temp' THEN '°C'
93
+ WHEN unpivot.measure = 'water_pot' THEN 'kPa'
94
+ WHEN unpivot.measure = 'dendro_circ' THEN 'mm'
95
+ WHEN unpivot.measure = 'dendro_gain' THEN 'µm'
96
+ ELSE NULL
97
+ END AS unit
98
+ FROM
99
+ sensor_devices_import s,
100
+ LATERAL (
101
+ VALUES ('air_temp',s.air_temp),
102
+ ('air_hum',s.air_hum),
103
+ ('pressure',s.pressure),
104
+ ('wind_dir',s.wind_dir),
105
+ ('wind_impact',s.wind_impact),
106
+ ('wind_speed',s.wind_speed),
107
+ ('precip',s.precip),
108
+ ('sun_irr',s.sun_irr),
109
+ ('soil_temp',s.soil_temp),
110
+ ('water_pot',s.water_pot),
111
+ ('dendro_circ',s.dendro_circ),
112
+ ('dendro_gain',s.dendro_gain)
113
+ )
114
+ unpivot(measure, height_cm)
115
+ WHERE height_cm IS NOT NULL
116
+ ),
117
+ measurements AS (
118
+ SELECT
119
+ m.sensor_id,
120
+ m.measured_at,
121
+ unpivot.measure,
122
+ unpivot.value
123
+ FROM
124
+ measurements m,
125
+ LATERAL (
126
+ VALUES
127
+ ('air_temp',m.air_temp),
128
+ ('air_hum',m.air_hum),
129
+ ('pressure',m.pressure),
130
+ ('wind_dir', CASE
131
+ WHEN m.wind_dir = 'N' THEN 0
132
+ WHEN m.wind_dir = 'NE' THEN 45
133
+ WHEN m.wind_dir = 'E' THEN 90
134
+ WHEN m.wind_dir = 'SE' THEN 135
135
+ WHEN m.wind_dir = 'S' THEN 180
136
+ WHEN m.wind_dir = 'SW' THEN 225
137
+ WHEN m.wind_dir = 'W' THEN 270
138
+ WHEN m.wind_dir = 'NW' THEN 315
139
+ ELSE NULL END),
140
+ ('wind_impact',m.wind_impact),
141
+ ('wind_speed',m.wind_speed),
142
+ ('precip',m.precip),
143
+ ('sun_irr',m.sun_irr),
144
+ ('soil_temp',m.soil_temp),
145
+ ('water_pot',m.water_pot),
146
+ ('dendro_circ',m.dendro_circ),
147
+ ('dendro_gain',m.dendro_gain)
148
+ )
149
+ unpivot(measure, value)
150
+ WHERE value IS NOT NULL
151
+ )
152
+ SELECT
153
+ q.*,
154
+ row_number() OVER (PARTITION BY point_id, measure ORDER BY point_id ASC, measure ASC, measured_at DESC) rn
155
+ FROM (
156
+ SELECT
157
+ measurements.sensor_id,
158
+ measurements.measured_at,
159
+ points_heights.point_id,
160
+ points_heights.location_id,
161
+ CONCAT(measurements.measure, points_heights.height_cm) AS measure,
162
+ measurements.value,
163
+ points_heights.unit
164
+ FROM measurements
165
+ JOIN points_heights
166
+ ON points_heights.sensor_id = measurements.sensor_id
167
+ AND points_heights.measure = measurements.measure
168
+ ) as q
169
+ ORDER BY point_id ASC, measure ASC, measured_at DESC;
170
+
171
+ CREATE INDEX measured_at_idx ON measurements (measured_at DESC);
172
+ CREATE INDEX sensor_id_idx ON measurements (sensor_id);
@@ -1 +1 @@
1
- {"version":3,"file":"RefreshMeasurementsByIdTaskSchema.js","sourceRoot":"","sources":["../../../src/integration-engine/schema/RefreshMeasurementsByIdTaskSchema.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+EAAwF;AACxF,wEAA4E;AAE5E,MAAa,iCAAiC;CAW7C;AATG;IADC,IAAA,0BAAQ,GAAE;;qEACS;AAGpB;IADC,IAAA,wBAAM,EAAC,wBAAS,CAAC;;oEACI;AAL1B,8EAWC"}
1
+ {"version":3,"file":"RefreshMeasurementsByIdTaskSchema.js","sourceRoot":"","sources":["../../../src/integration-engine/schema/RefreshMeasurementsByIdTaskSchema.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+EAA6E;AAC7E,wEAA4E;AAE5E,MAAa,iCAAiC;CAW7C;AATG;IADC,IAAA,0BAAQ,GAAE;;qEACS;AAGpB;IADC,IAAA,wBAAM,EAAC,wBAAS,CAAC;;oEACI;AAL1B,8EAWC"}
@@ -0,0 +1,4 @@
1
+ /// <reference types="express" />
2
+ import { Router } from "@golemio/core/dist/shared/express";
3
+ declare const microclimateRouter: Router;
4
+ export { microclimateRouter };
@@ -0,0 +1,85 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.microclimateRouter = void 0;
13
+ const express_1 = require("@golemio/core/dist/shared/express");
14
+ const express_validator_1 = require("@golemio/core/dist/shared/express-validator");
15
+ const BaseRouter_1 = require("@golemio/core/dist/output-gateway/routes/BaseRouter");
16
+ const output_gateway_1 = require("@golemio/core/dist/output-gateway");
17
+ const repositories_1 = require("./repositories");
18
+ const LocationsOutputMapper_1 = require("./helpers/LocationsOutputMapper");
19
+ const SensorPointsViewRepository_1 = require("./repositories/SensorPointsViewRepository");
20
+ const SensorMeasurementsViewRepository_1 = require("./repositories/SensorMeasurementsViewRepository");
21
+ const PointsOutputMapper_1 = require("./helpers/PointsOutputMapper");
22
+ class MicroclimateRouter extends BaseRouter_1.BaseRouter {
23
+ constructor() {
24
+ super();
25
+ this.router = (0, express_1.Router)();
26
+ this.getLocations = (req, res, next) => __awaiter(this, void 0, void 0, function* () {
27
+ try {
28
+ const data = yield this.sensorDevicesImportRepository.GetAllDistinctLocations({
29
+ locationId: req.query.locationId ? Number(req.query.locationId) : undefined,
30
+ });
31
+ res.status(200).send(LocationsOutputMapper_1.LocationsOutputMapper.locationsMapper(data));
32
+ }
33
+ catch (err) {
34
+ next(err);
35
+ }
36
+ });
37
+ this.getPoints = (req, res, next) => __awaiter(this, void 0, void 0, function* () {
38
+ try {
39
+ const data = yield this.sensorPointsViewRepository.GetAllPoints({
40
+ locationId: req.query.locationId ? Number(req.query.locationId) : undefined,
41
+ pointId: req.query.pointId ? Number(req.query.pointId) : undefined,
42
+ });
43
+ res.status(200).send(PointsOutputMapper_1.PointsOutputMapper.pointsMapper(data));
44
+ }
45
+ catch (err) {
46
+ next(err);
47
+ }
48
+ });
49
+ this.getMeasurements = (req, res, next) => __awaiter(this, void 0, void 0, function* () {
50
+ try {
51
+ const data = yield this.sensorMeasurementsViewRepository.GetAllMeasurements({
52
+ locationId: req.query.locationId ? Number(req.query.locationId) : undefined,
53
+ pointId: req.query.pointId ? Number(req.query.pointId) : undefined,
54
+ measure: req.query.measure,
55
+ from: req.query.from,
56
+ to: req.query.to,
57
+ limit: req.query.limit ? Number(req.query.limit) : undefined,
58
+ offset: req.query.offset ? Number(req.query.offset) : undefined,
59
+ });
60
+ res.status(200).send(data);
61
+ }
62
+ catch (err) {
63
+ next(err);
64
+ }
65
+ });
66
+ this.initRoutes = () => {
67
+ this.router.get("/locations", [(0, express_validator_1.query)("locationId'").optional().isInt()], output_gateway_1.checkErrors, (0, output_gateway_1.useCacheMiddleware)(), this.getLocations);
68
+ this.router.get("/points", [(0, express_validator_1.query)("locationId'").optional().isInt(), (0, express_validator_1.query)("pointId").optional().isInt()], output_gateway_1.checkErrors, (0, output_gateway_1.useCacheMiddleware)(), this.getPoints);
69
+ this.router.get("/measurements", [
70
+ (0, express_validator_1.query)("locationId'").optional().isInt(),
71
+ (0, express_validator_1.query)("pointId").optional().isInt(),
72
+ (0, express_validator_1.query)("measure").optional().isString(),
73
+ (0, express_validator_1.query)("from").optional().isISO8601(),
74
+ (0, express_validator_1.query)("to").optional().isISO8601(),
75
+ ], output_gateway_1.pagination, output_gateway_1.checkErrors, (0, output_gateway_1.useCacheMiddleware)(), this.getMeasurements);
76
+ };
77
+ this.sensorDevicesImportRepository = new repositories_1.SensorDevicesImportRepository();
78
+ this.sensorPointsViewRepository = new SensorPointsViewRepository_1.SensorPointsViewRepository();
79
+ this.sensorMeasurementsViewRepository = new SensorMeasurementsViewRepository_1.SensorMeasurementsViewRepository();
80
+ this.initRoutes();
81
+ }
82
+ }
83
+ const microclimateRouter = new MicroclimateRouter().router;
84
+ exports.microclimateRouter = microclimateRouter;
85
+ //# sourceMappingURL=MicroclimateRouter.js.map
@@ -0,0 +1 @@
1
+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E,IAAI,CAAC,0BAA0B,GAAG,IAAI,uDAA0B,EAAE,CAAC;QACnE,IAAI,CAAC,gCAAgC,GAAG,IAAI,mEAAgC,EAAE,CAAC;QAC/E,IAAI,CAAC,UAAU,EAAE,CAAC;IACtB,CAAC;CAwEJ;AAED,MAAM,kBAAkB,GAAW,IAAI,kBAAkB,EAAE,CAAC,MAAM,CAAC;AAE1D,gDAAkB"}
@@ -0,0 +1,18 @@
1
+ import { ILocationRecord } from "../repositories";
2
+ interface IPointOutput {
3
+ point_id: number;
4
+ point_name: string;
5
+ }
6
+ export interface ILocationOutput {
7
+ location_id: number;
8
+ location: string;
9
+ loc_description: string;
10
+ loc_orientation: string;
11
+ loc_surface: string;
12
+ address: string;
13
+ points: IPointOutput[];
14
+ }
15
+ export declare class LocationsOutputMapper {
16
+ static locationsMapper: (records: ILocationRecord[]) => ILocationOutput[];
17
+ }
18
+ export {};
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LocationsOutputMapper = void 0;
4
+ class LocationsOutputMapper {
5
+ }
6
+ exports.LocationsOutputMapper = LocationsOutputMapper;
7
+ LocationsOutputMapper.locationsMapper = (records) => {
8
+ const locationMap = {};
9
+ for (const record of records) {
10
+ if (locationMap[record.location_id]) {
11
+ locationMap[record.location_id].points.push({
12
+ point_id: record.point_id,
13
+ point_name: record.point_name,
14
+ });
15
+ }
16
+ else {
17
+ locationMap[record.location_id] = {
18
+ location_id: record.location_id,
19
+ location: record.location,
20
+ loc_description: record.loc_description,
21
+ loc_orientation: record.loc_orientation,
22
+ loc_surface: record.loc_surface,
23
+ address: record.address,
24
+ points: [
25
+ {
26
+ point_id: record.point_id,
27
+ point_name: record.point_name,
28
+ },
29
+ ],
30
+ };
31
+ }
32
+ }
33
+ return Object.values(locationMap);
34
+ };
35
+ //# sourceMappingURL=LocationsOutputMapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LocationsOutputMapper.js","sourceRoot":"","sources":["../../../src/output-gateway/helpers/LocationsOutputMapper.ts"],"names":[],"mappings":";;;AAiBA,MAAa,qBAAqB;;AAAlC,sDA6BC;AA5BiB,qCAAe,GAAG,CAAC,OAA0B,EAAqB,EAAE;IAC9E,MAAM,WAAW,GAAoC,EAAE,CAAC;IACxD,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;QAC1B,IAAI,WAAW,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE;YACjC,WAAW,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC;gBACxC,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,UAAU,EAAE,MAAM,CAAC,UAAU;aAChC,CAAC,CAAC;SACN;aAAM;YACH,WAAW,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG;gBAC9B,WAAW,EAAE,MAAM,CAAC,WAAW;gBAC/B,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,eAAe,EAAE,MAAM,CAAC,eAAe;gBACvC,eAAe,EAAE,MAAM,CAAC,eAAe;gBACvC,WAAW,EAAE,MAAM,CAAC,WAAW;gBAC/B,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,MAAM,EAAE;oBACJ;wBACI,QAAQ,EAAE,MAAM,CAAC,QAAQ;wBACzB,UAAU,EAAE,MAAM,CAAC,UAAU;qBAChC;iBACJ;aACJ,CAAC;SACL;KACJ;IAED,OAAO,MAAM,CAAC,MAAM,CAAkB,WAAW,CAAC,CAAC;AACvD,CAAC,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { ISensorPointsView } from "../../schema-definitions/SensorPointsView";
2
+ interface ISensorPointsViewMeasurementOutput {
3
+ measure: string;
4
+ measure_cz: string;
5
+ unit: string;
6
+ }
7
+ export interface ISensorPointsViewOutput {
8
+ point_id: number;
9
+ location_id: number;
10
+ point_name: string;
11
+ location: string;
12
+ loc_description: string;
13
+ loc_orientation: string;
14
+ loc_surface: string;
15
+ lat: number;
16
+ lng: number;
17
+ x_jtsk: number | null;
18
+ y_jtsk: number | null;
19
+ elevation_m: number | null;
20
+ measures: ISensorPointsViewMeasurementOutput[];
21
+ sensor_position: string;
22
+ sensor_position_detail: string;
23
+ }
24
+ export declare class PointsOutputMapper {
25
+ static pointsMapper: (records: ISensorPointsView[]) => ISensorPointsViewOutput[];
26
+ }
27
+ export {};
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PointsOutputMapper = void 0;
4
+ class PointsOutputMapper {
5
+ }
6
+ exports.PointsOutputMapper = PointsOutputMapper;
7
+ PointsOutputMapper.pointsMapper = (records) => {
8
+ const pointsMap = {};
9
+ for (const record of records) {
10
+ if (pointsMap[record.point_id]) {
11
+ pointsMap[record.point_id].measures.push({
12
+ measure: record.measure,
13
+ measure_cz: record.measure_cz,
14
+ unit: record.unit,
15
+ });
16
+ }
17
+ else {
18
+ pointsMap[record.point_id] = {
19
+ point_id: record.point_id,
20
+ location_id: record.location_id,
21
+ point_name: record.point_name,
22
+ location: record.location,
23
+ loc_description: record.loc_description,
24
+ loc_orientation: record.loc_orientation,
25
+ loc_surface: record.loc_surface,
26
+ lat: record.lat,
27
+ lng: record.lng,
28
+ x_jtsk: record.x_jtsk,
29
+ y_jtsk: record.y_jtsk,
30
+ elevation_m: record.elevation_m,
31
+ measures: [
32
+ {
33
+ measure: record.measure,
34
+ measure_cz: record.measure_cz,
35
+ unit: record.unit,
36
+ },
37
+ ],
38
+ sensor_position: record.sensor_position,
39
+ sensor_position_detail: record.sensor_position_detail,
40
+ };
41
+ }
42
+ }
43
+ return Object.values(pointsMap);
44
+ };
45
+ //# sourceMappingURL=PointsOutputMapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PointsOutputMapper.js","sourceRoot":"","sources":["../../../src/output-gateway/helpers/PointsOutputMapper.ts"],"names":[],"mappings":";;;AA0BA,MAAa,kBAAkB;;AAA/B,gDAuCC;AAtCiB,+BAAY,GA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@
1
+ export * from "./MicroclimateRouter";
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./MicroclimateRouter"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/output-gateway/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC"}
@@ -0,0 +1,19 @@
1
+ import { SequelizeModel } from "@golemio/core/dist/output-gateway";
2
+ export interface ILocationRecord {
3
+ location_id: number;
4
+ location: string;
5
+ loc_description: string;
6
+ loc_orientation: string;
7
+ loc_surface: string;
8
+ address: string;
9
+ point_id: number;
10
+ point_name: string;
11
+ }
12
+ export declare class SensorDevicesImportRepository extends SequelizeModel {
13
+ constructor();
14
+ GetAllDistinctLocations: (options?: {
15
+ locationId?: number;
16
+ }) => Promise<ILocationRecord[]>;
17
+ GetAll(): never;
18
+ GetOne(): never;
19
+ }
@@ -0,0 +1,55 @@
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.SensorDevicesImportRepository = void 0;
16
+ const output_gateway_1 = require("@golemio/core/dist/output-gateway");
17
+ const sequelize_1 = __importDefault(require("@golemio/core/dist/shared/sequelize"));
18
+ const _sch_1 = require("../../schema-definitions");
19
+ const SensorDevicesImportModel_1 = require("../../schema-definitions/models/SensorDevicesImportModel");
20
+ class SensorDevicesImportRepository extends output_gateway_1.SequelizeModel {
21
+ constructor() {
22
+ super(_sch_1.Microclimate.definitions.sensorDevicesImport.name, _sch_1.Microclimate.definitions.sensorDevicesImport.pgTableName, SensorDevicesImportModel_1.SensorDevicesImportModel.attributeModel, {
23
+ schema: _sch_1.Microclimate.pgSchema,
24
+ });
25
+ this.GetAllDistinctLocations = (options = {}) => __awaiter(this, void 0, void 0, function* () {
26
+ let whereCondition = "";
27
+ if (options.locationId) {
28
+ whereCondition = `WHERE location_id = ${options.locationId}`;
29
+ }
30
+ return this.sequelizeModel.sequelize.query(`
31
+ SELECT DISTINCT
32
+ location_id,
33
+ point_id,
34
+ location,
35
+ loc_description,
36
+ loc_orientation,
37
+ loc_surface,
38
+ point_name,
39
+ address
40
+ FROM ${_sch_1.Microclimate.pgSchema}.sensor_devices_import
41
+ ${whereCondition}
42
+ ORDER BY location_id ASC, point_id ASC
43
+ ;
44
+ `, { type: sequelize_1.default.QueryTypes.SELECT });
45
+ });
46
+ }
47
+ GetAll() {
48
+ throw new Error("Not implemented");
49
+ }
50
+ GetOne() {
51
+ throw new Error("Not implemented");
52
+ }
53
+ }
54
+ exports.SensorDevicesImportRepository = SensorDevicesImportRepository;
55
+ //# sourceMappingURL=SensorDevicesImportRepository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SensorDevicesImportRepository.js","sourceRoot":"","sources":["../../../src/output-gateway/repositories/SensorDevicesImportRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sEAAmE;AACnE,oFAA4D;AAC5D,mDAAoC;AACpC,uGAAgF;AAahF,MAAa,6BAA8B,SAAQ,+BAAc;IAC7D;QACI,KAAK,CACD,mBAAY,CAAC,WAAW,CAAC,mBAAmB,CAAC,IAAI,EACjD,mBAAY,CAAC,WAAW,CAAC,mBAAmB,CAAC,WAAW,EACxD,mDAAwB,CAAC,cAAc,EACvC;YACI,MAAM,EAAE,mBAAY,CAAC,QAAQ;SAChC,CACJ,CAAC;QAGC,4BAAuB,GAAG,CAC7B,UAEI,EAAE,EACoB,EAAE;YAC5B,IAAI,cAAc,GAAG,EAAE,CAAC;YACxB,IAAI,OAAO,CAAC,UAAU,EAAE;gBACpB,cAAc,GAAG,uBAAuB,OAAO,CAAC,UAAU,EAAE,CAAC;aAChE;YAED,OAAO,IAAI,CAAC,cAAc,CAAC,SAAU,CAAC,KAAK,CACvC;;;;;;;;;;mBAUO,mBAAY,CAAC,QAAQ;cAC1B,cAAc;;;SAGnB,EACG,EAAE,IAAI,EAAE,mBAAS,CAAC,UAAU,CAAC,MAAM,EAAE,CACxC,CAAC;QACN,CAAC,CAAA,CAAC;IA9BF,CAAC;IAgCD,MAAM;QACF,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACvC,CAAC;IAED,MAAM;QACF,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACvC,CAAC;CACJ;AAjDD,sEAiDC"}