@golemio/rush-hour-aggregation 1.0.0 → 1.0.1
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/README.md +61 -21
- package/db/migrations/postgresql/20220505053742-addMaterialViews.js +53 -0
- package/db/migrations/postgresql/sqls/20220505053742-addMaterialViews-down.sql +10 -0
- package/db/migrations/postgresql/sqls/20220505053742-addMaterialViews-up.sql +565 -0
- package/dist/integration-engine/AggregationWorker.d.ts +2 -0
- package/dist/integration-engine/AggregationWorker.js +14 -2
- package/dist/integration-engine/AggregationWorker.js.map +1 -1
- package/dist/integration-engine/dataAccess/AbstractEventsRepository.d.ts +9 -0
- package/dist/integration-engine/dataAccess/AbstractEventsRepository.js +35 -0
- package/dist/integration-engine/dataAccess/AbstractEventsRepository.js.map +1 -0
- package/dist/integration-engine/dataAccess/FcdEventsRepository.d.ts +4 -2
- package/dist/integration-engine/dataAccess/FcdEventsRepository.js +4 -2
- package/dist/integration-engine/dataAccess/FcdEventsRepository.js.map +1 -1
- package/dist/integration-engine/dataAccess/NdicEventRepository.d.ts +4 -2
- package/dist/integration-engine/dataAccess/NdicEventRepository.js +4 -2
- package/dist/integration-engine/dataAccess/NdicEventRepository.js.map +1 -1
- package/dist/integration-engine/dataAccess/TskEventsRepository.d.ts +4 -2
- package/dist/integration-engine/dataAccess/TskEventsRepository.js +4 -2
- package/dist/integration-engine/dataAccess/TskEventsRepository.js.map +1 -1
- package/dist/integration-engine/dataAccess/WazeJamsRepository.d.ts +4 -2
- package/dist/integration-engine/dataAccess/WazeJamsRepository.js +4 -2
- package/dist/integration-engine/dataAccess/WazeJamsRepository.js.map +1 -1
- package/dist/integration-engine/dataAccess/WazeReconstructionsRepository.d.ts +4 -2
- package/dist/integration-engine/dataAccess/WazeReconstructionsRepository.js +4 -2
- package/dist/integration-engine/dataAccess/WazeReconstructionsRepository.js.map +1 -1
- package/dist/integration-engine/queueDefinitions.js +10 -0
- package/dist/integration-engine/queueDefinitions.js.map +1 -1
- package/dist/integration-engine/service/AggregationFactory.d.ts +2 -2
- package/dist/integration-engine/service/AggregationFactory.js.map +1 -1
- package/dist/integration-engine/service/aggregators/AbstractAggregator.d.ts +7 -3
- package/dist/integration-engine/service/aggregators/AbstractAggregator.js +8 -0
- package/dist/integration-engine/service/aggregators/AbstractAggregator.js.map +1 -1
- package/dist/integration-engine/service/aggregators/FcdEventsAggregator.d.ts +3 -3
- package/dist/integration-engine/service/aggregators/FcdEventsAggregator.js +0 -4
- package/dist/integration-engine/service/aggregators/FcdEventsAggregator.js.map +1 -1
- package/dist/integration-engine/service/aggregators/NdicEventsAggregator.d.ts +3 -3
- package/dist/integration-engine/service/aggregators/NdicEventsAggregator.js +0 -4
- package/dist/integration-engine/service/aggregators/NdicEventsAggregator.js.map +1 -1
- package/dist/integration-engine/service/aggregators/TskEventsAggregator.d.ts +3 -3
- package/dist/integration-engine/service/aggregators/TskEventsAggregator.js +0 -4
- package/dist/integration-engine/service/aggregators/TskEventsAggregator.js.map +1 -1
- package/dist/integration-engine/service/aggregators/WazeJamsAggregator.d.ts +3 -3
- package/dist/integration-engine/service/aggregators/WazeJamsAggregator.js +0 -4
- package/dist/integration-engine/service/aggregators/WazeJamsAggregator.js.map +1 -1
- package/dist/integration-engine/service/aggregators/WazeReconstructionsAggregator.d.ts +3 -3
- package/dist/integration-engine/service/aggregators/WazeReconstructionsAggregator.js +0 -4
- package/dist/integration-engine/service/aggregators/WazeReconstructionsAggregator.js.map +1 -1
- package/dist/integration-engine/service/aggregators/interfaces/IAbstractAggregator.d.ts +6 -0
- package/dist/integration-engine/service/aggregators/interfaces/IAbstractAggregator.js +3 -0
- package/dist/integration-engine/service/aggregators/interfaces/IAbstractAggregator.js.map +1 -0
- package/package.json +2 -2
- package/templates/sqlQueries/FcdEvents.sql +1 -1
- package/templates/sqlQueries/NdicEventsFull.sql +2 -2
package/README.md
CHANGED
|
@@ -1,47 +1,87 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
<p>
|
|
3
|
+
<a href="https://operatorict.cz">
|
|
4
|
+
<img src="https://gitlab.com/operator-ict/golemio/code/modules/core/-/raw/development/.assets/oict_logo.png" alt="oict" width="100px" height="100px" />
|
|
5
|
+
</a>
|
|
6
|
+
<a href="https://golemio.cz">
|
|
7
|
+
<img src="https://gitlab.com/operator-ict/golemio/code/modules/core/-/raw/development/.assets/golemio_logo.png" alt="golemio" width="100px" height="100px" />
|
|
8
|
+
</a>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<h1>@golemio/rush-hour-aggregation</h1>
|
|
12
|
+
|
|
13
|
+
<p>
|
|
14
|
+
<a href="https://gitlab.com/operator-ict/golemio/code/modules/rush-hour-aggregation/commits/master">
|
|
15
|
+
<img src="https://gitlab.com/operator-ict/golemio/code/modules/rush-hour-aggregation/badges/master/pipeline.svg" alt="pipeline">
|
|
16
|
+
</a>
|
|
17
|
+
<a href="https://gitlab.com/operator-ict/golemio/code/modules/rush-hour-aggregation/commits/master">
|
|
18
|
+
<img src="https://gitlab.com/operator-ict/golemio/code/modules/rush-hour-aggregation/badges/master/coverage.svg" alt="coverage">
|
|
19
|
+
</a>
|
|
20
|
+
<a href="./LICENSE">
|
|
21
|
+
<img src="https://img.shields.io/npm/l/@golemio/rush-hour-aggregation" alt="license">
|
|
22
|
+
</a>
|
|
23
|
+
</p>
|
|
24
|
+
|
|
25
|
+
<p>
|
|
26
|
+
<a href="#installation">Installation</a> · <a href="./docs">Documentation</a> · <a href="https://operator-ict.gitlab.io/golemio/code/modules/rush-hour-aggregation">TypeDoc</a>
|
|
27
|
+
</p>
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
This module is intended for use with Golemio services. Refer [here](https://gitlab.com/operator-ict/golemio/code/modules/core/-/blob/development/README.md) for further information on usage, local development and more.
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
The APIs may be unstable. Therefore, we recommend to install this module as an exact version.
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# Latest version
|
|
38
|
+
yarn add --exact @golemio/rush-hour-aggregation@latest
|
|
39
|
+
|
|
40
|
+
# Development version
|
|
41
|
+
yarn add --exact @golemio/rush-hour-aggregation@dev
|
|
42
|
+
```
|
|
3
43
|
|
|
4
|
-
|
|
44
|
+
## Description
|
|
5
45
|
|
|
6
|
-
|
|
46
|
+
This module aggregates traffic data for Praha Zasekana project. It takes different traffic dataset avaiable in a golemio dataplatform and creates time series data for traffic jams, incidents or reconstructions.
|
|
7
47
|
|
|
8
|
-
[Rabin Praha Zasekana](https://praha-zasekana-backend.rabin.golemio.cz/app)
|
|
48
|
+
[Rabin Praha Zasekana](https://praha-zasekana-backend.rabin.golemio.cz/app)
|
|
9
49
|
[Backend repo Praha Zasekana](https://gitlab.com/operator-ict/golemio/code/praha-zasekana)
|
|
10
50
|
|
|
11
|
-
|
|
51
|
+
## Datasources
|
|
12
52
|
|
|
13
|
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
- NDIC
|
|
53
|
+
- Waze
|
|
54
|
+
- SDDŘ
|
|
55
|
+
- FCD
|
|
56
|
+
- NDIC
|
|
18
57
|
|
|
19
|
-
|
|
58
|
+
## Current setup
|
|
20
59
|
|
|
21
60
|
Every 5 minutes worker starts and for each of the datasource aggregation is run and timeseries data are updated.
|
|
22
61
|
|
|
23
|
-
|
|
62
|
+
## Aggregation of older data
|
|
24
63
|
|
|
25
64
|
It is possible to insert or update historic data by creation of manual message in RabbitMQ.
|
|
26
65
|
E.g. to insert data for Fcd for first month in 2022 use following message:
|
|
27
66
|
|
|
28
67
|
```json
|
|
29
68
|
{
|
|
30
|
-
"from":"2020-01-01T00:00:00Z",
|
|
31
|
-
"to":"2020-01-31T23:59:59Z",
|
|
32
|
-
"type":"fcd"
|
|
69
|
+
"from": "2020-01-01T00:00:00Z",
|
|
70
|
+
"to": "2020-01-31T23:59:59Z",
|
|
71
|
+
"type": "fcd"
|
|
33
72
|
}
|
|
34
73
|
```
|
|
35
74
|
|
|
36
|
-
|
|
75
|
+
## Message building blocks
|
|
76
|
+
|
|
37
77
|
Message has to be in json format and supports following fields:
|
|
38
78
|
|
|
39
|
-
|
|
79
|
+
_from_ - Required date time setting when the aggregation has to start. It is formatted in ISO 8601 preferably UTC format with Z at the end
|
|
40
80
|
|
|
41
|
-
|
|
81
|
+
_to_ - Required date time setting when the aggregation has is ending. It is formatted in ISO 8601 preferably UTC format with Z at the end
|
|
42
82
|
|
|
43
|
-
|
|
83
|
+
_type_ - Required setting which aggregation should be run. Possible values: WAZEJ, WAZER, SDDR, FCD, NDIC. (Case insensitive)
|
|
44
84
|
|
|
45
|
-
|
|
85
|
+
_updateOnDuplicate_ - Optional setting for situation when upgrade of already aggregated data is required. Possible values "true", "false". Default value is false. (Note: automatic 5 minute updates have the setting to true)
|
|
46
86
|
|
|
47
87
|
To initiate automatic 5 minute aggregation manually it is possible to send empty message.
|
|
@@ -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', '20220505053742-addMaterialViews-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', '20220505053742-addMaterialViews-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,10 @@
|
|
|
1
|
+
DROP MATERIALIZED VIEW IF EXISTS waze_reconstructions_snapshots_history;
|
|
2
|
+
DROP MATERIALIZED VIEW IF EXISTS waze_reconstructions_snapshots_latest;
|
|
3
|
+
DROP MATERIALIZED VIEW IF EXISTS waze_jams_snapshots_history;
|
|
4
|
+
DROP MATERIALIZED VIEW IF EXISTS waze_jams_snapshots_latest;
|
|
5
|
+
DROP MATERIALIZED VIEW IF EXISTS tsk_std_last_30min_snapshots_history;
|
|
6
|
+
DROP MATERIALIZED VIEW IF EXISTS tsk_std_last_30min_snapshots_latest;
|
|
7
|
+
DROP MATERIALIZED VIEW IF EXISTS ndic_events_full_snapshots_history;
|
|
8
|
+
DROP MATERIALIZED VIEW IF EXISTS ndic_events_full_snapshots_latest;
|
|
9
|
+
DROP MATERIALIZED VIEW IF EXISTS fcd_events_snapshots_history;
|
|
10
|
+
DROP MATERIALIZED VIEW IF EXISTS fcd_events_snapshots_latest;
|