@golemio/microclimate 1.0.3 → 1.0.4-dev.735991902
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 +27 -0
- package/dist/integration-engine/datasources/MeasurementsDataSourceFactory.js +2 -2
- package/dist/integration-engine/datasources/MeasurementsDataSourceFactory.js.map +1 -1
- package/dist/integration-engine/schema/RefreshMeasurementsByIdTaskSchema.d.ts +2 -1
- package/dist/integration-engine/schema/RefreshMeasurementsByIdTaskSchema.js +5 -0
- package/dist/integration-engine/schema/RefreshMeasurementsByIdTaskSchema.js.map +1 -1
- package/dist/integration-engine/workers/tasks/RefreshMeasurementsTask.js +2 -0
- package/dist/integration-engine/workers/tasks/RefreshMeasurementsTask.js.map +1 -1
- package/dist/schema-definitions/Measurements.d.ts +11 -0
- package/dist/schema-definitions/Measurements.js +12 -1
- package/dist/schema-definitions/Measurements.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -44,3 +44,30 @@ yarn add --exact @golemio/microclimate@dev
|
|
|
44
44
|
<!-- ## Description -->
|
|
45
45
|
|
|
46
46
|
<!-- Insert module-specific info here -->
|
|
47
|
+
|
|
48
|
+
## Processing of historical data
|
|
49
|
+
|
|
50
|
+
To trigger the measurement data processing of a specific sensor for a specific period, use the queue in RabbitMQ `...microclimate.refreshMeasurementsById` according to the template:
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
{
|
|
54
|
+
"sensorAddr": "323434316F317A18",
|
|
55
|
+
"dateRange": "currentYear"
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Where:
|
|
60
|
+
|
|
61
|
+
`sensorAddr` - Represents the transmitter's unique identifier. (Table `sensor_devices`, variable `address`)
|
|
62
|
+
|
|
63
|
+
`dateRange` - Time period: "today", "yesterday", "currentWeek", "previousWeek", "currentMonth", "previousMonth", "currentYear", "previousYear"
|
|
64
|
+
|
|
65
|
+
If an error is made in the RabbitMQ msg, the program will not crash, but will continue to work. It will also log an error of the type:
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
error: {
|
|
69
|
+
message:
|
|
70
|
+
"[Queue ....microclimate.refreshMeasurementsById] Message validation failed: [dateRange must be one of the following values: today, yesterday, currentWeek, previousWeek, currentMonth, previousMonth, currentYear, previousYear]",
|
|
71
|
+
class_name: "MessageDataValidator",
|
|
72
|
+
}
|
|
73
|
+
```
|
|
@@ -7,7 +7,7 @@ const golemio_validator_1 = require("@golemio/core/dist/shared/golemio-validator
|
|
|
7
7
|
const _sch_1 = require("../../schema-definitions");
|
|
8
8
|
class MeasurementsDataSourceFactory {
|
|
9
9
|
static getDataSource(params) {
|
|
10
|
-
const { sensorAddr,
|
|
10
|
+
const { sensorAddr, dateRange,
|
|
11
11
|
// For future FROM-TO implementation:
|
|
12
12
|
// dateFrom,
|
|
13
13
|
// dateTo
|
|
@@ -15,7 +15,7 @@ class MeasurementsDataSourceFactory {
|
|
|
15
15
|
return new datasources_1.DataSource(_sch_1.Microclimate.datasources.measurementsDatasource.name, new datasources_1.HTTPProtocolStrategy({
|
|
16
16
|
headers: { Authorization: "Bearer " + config_1.config.datasources.MicroclimateAgdataCityApikey },
|
|
17
17
|
method: "GET",
|
|
18
|
-
url: `${config_1.config.datasources.MicroclimateAgdataCity}?sensorAddr=${sensorAddr}&dateRange
|
|
18
|
+
url: `${config_1.config.datasources.MicroclimateAgdataCity}?sensorAddr=${sensorAddr}&dateRange=${dateRange}`,
|
|
19
19
|
}), new datasources_1.JSONDataTypeStrategy({ resultsPath: "data" }), new golemio_validator_1.JSONSchemaValidator(_sch_1.Microclimate.datasources.measurementsDatasource.name + "Validator", _sch_1.Microclimate.datasources.measurementsDatasource.jsonSchema, true));
|
|
20
20
|
}
|
|
21
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MeasurementsDataSourceFactory.js","sourceRoot":"","sources":["../../../src/integration-engine/datasources/MeasurementsDataSourceFactory.ts"],"names":[],"mappings":";;;AAAA,mFAA2H;AAC3H,yEAAsE;AACtE,mFAAkF;AAClF,mDAAoC;AAGpC,MAAa,6BAA6B;IAC/B,MAAM,CAAC,aAAa,CAAC,MAAoC;QAC5D,MAAM,EACF,UAAU;
|
|
1
|
+
{"version":3,"file":"MeasurementsDataSourceFactory.js","sourceRoot":"","sources":["../../../src/integration-engine/datasources/MeasurementsDataSourceFactory.ts"],"names":[],"mappings":";;;AAAA,mFAA2H;AAC3H,yEAAsE;AACtE,mFAAkF;AAClF,mDAAoC;AAGpC,MAAa,6BAA6B;IAC/B,MAAM,CAAC,aAAa,CAAC,MAAoC;QAC5D,MAAM,EACF,UAAU,EACV,SAAS;QACT,qCAAqC;QACrC,YAAY;QACZ,SAAS;UACZ,GAAG,MAAM,CAAC;QACX,OAAO,IAAI,wBAAU,CACjB,mBAAY,CAAC,WAAW,CAAC,sBAAsB,CAAC,IAAI,EACpD,IAAI,kCAAoB,CAAC;YACrB,OAAO,EAAE,EAAE,aAAa,EAAE,SAAS,GAAG,eAAM,CAAC,WAAW,CAAC,4BAA4B,EAAE;YACvF,MAAM,EAAE,KAAK;YACb,GAAG,EAAE,GAAG,eAAM,CAAC,WAAW,CAAC,sBAAsB,eAAe,UAAU,cAAc,SAAS,EAAE;SACtG,CAAC,EACF,IAAI,kCAAoB,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,EACjD,IAAI,uCAAmB,CACnB,mBAAY,CAAC,WAAW,CAAC,sBAAsB,CAAC,IAAI,GAAG,WAAW,EAClE,mBAAY,CAAC,WAAW,CAAC,sBAAsB,CAAC,UAAU,EAC1D,IAAI,CACP,CACJ,CAAC;IACN,CAAC;CACJ;AAxBD,sEAwBC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { IRefreshMeasurementsByIdTask } from "../../schema-definitions/Measurements";
|
|
1
|
+
import { DateRange, IRefreshMeasurementsByIdTask } from "../../schema-definitions/Measurements";
|
|
2
2
|
export declare class RefreshMeasurementsByIdTaskSchema implements IRefreshMeasurementsByIdTask {
|
|
3
3
|
sensorAddr: string;
|
|
4
|
+
dateRange: DateRange;
|
|
4
5
|
}
|
|
@@ -11,11 +11,16 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.RefreshMeasurementsByIdTaskSchema = void 0;
|
|
13
13
|
const class_validator_1 = require("@golemio/core/dist/shared/class-validator");
|
|
14
|
+
const Measurements_1 = require("../../schema-definitions/Measurements");
|
|
14
15
|
class RefreshMeasurementsByIdTaskSchema {
|
|
15
16
|
}
|
|
16
17
|
__decorate([
|
|
17
18
|
(0, class_validator_1.IsString)(),
|
|
18
19
|
__metadata("design:type", String)
|
|
19
20
|
], RefreshMeasurementsByIdTaskSchema.prototype, "sensorAddr", void 0);
|
|
21
|
+
__decorate([
|
|
22
|
+
(0, class_validator_1.IsEnum)(Measurements_1.DateRange),
|
|
23
|
+
__metadata("design:type", String)
|
|
24
|
+
], RefreshMeasurementsByIdTaskSchema.prototype, "dateRange", void 0);
|
|
20
25
|
exports.RefreshMeasurementsByIdTaskSchema = RefreshMeasurementsByIdTaskSchema;
|
|
21
26
|
//# sourceMappingURL=RefreshMeasurementsByIdTaskSchema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RefreshMeasurementsByIdTaskSchema.js","sourceRoot":"","sources":["../../../src/integration-engine/schema/RefreshMeasurementsByIdTaskSchema.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+
|
|
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"}
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.RefreshMeasurementsTask = void 0;
|
|
13
13
|
const integration_engine_1 = require("@golemio/core/dist/integration-engine");
|
|
14
14
|
const repositories_1 = require("../../repositories");
|
|
15
|
+
const Measurements_1 = require("../../../schema-definitions/Measurements");
|
|
15
16
|
class RefreshMeasurementsTask extends integration_engine_1.AbstractEmptyTask {
|
|
16
17
|
constructor(queuePrefix) {
|
|
17
18
|
super(queuePrefix);
|
|
@@ -28,6 +29,7 @@ class RefreshMeasurementsTask extends integration_engine_1.AbstractEmptyTask {
|
|
|
28
29
|
const promises = sensorDevicesFromDB.map((sensorIdObject) => {
|
|
29
30
|
const msg = {
|
|
30
31
|
sensorAddr: sensorIdObject.sensor_id,
|
|
32
|
+
dateRange: Measurements_1.DateRange.TODAY,
|
|
31
33
|
};
|
|
32
34
|
return integration_engine_1.QueueManager.sendMessageToExchange(this.queuePrefix, "refreshMeasurementsById", msg);
|
|
33
35
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RefreshMeasurementsTask.js","sourceRoot":"","sources":["../../../../src/integration-engine/workers/tasks/RefreshMeasurementsTask.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8EAAwF;AACxF,qDAA2D;
|
|
1
|
+
{"version":3,"file":"RefreshMeasurementsTask.js","sourceRoot":"","sources":["../../../../src/integration-engine/workers/tasks/RefreshMeasurementsTask.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8EAAwF;AACxF,qDAA2D;AAC3D,2EAA4E;AAM5E,MAAa,uBAAwB,SAAQ,sCAAiB;IAM1D,YAAY,WAAmB;QAC3B,KAAK,CAAC,WAAW,CAAC,CAAC;QANP,cAAS,GAAG,qBAAqB,CAAC;QAClC,aAAQ,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,WAAW;QAMvD,IAAI,CAAC,UAAU,GAAG,IAAI,sCAAuB,EAAE,CAAC;IACpD,CAAC;IAEe,OAAO;;YACnB,MAAM,mBAAmB,GAAsB,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;gBACtE,UAAU,EAAE,CAAC,WAAW,CAAC;gBACzB,GAAG,EAAE,IAAI;aACZ,CAAC,CAAC;YAEH,MAAM,QAAQ,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC,cAAc,EAAE,EAAE;gBACxD,MAAM,GAAG,GAAiC;oBACtC,UAAU,EAAE,cAAc,CAAC,SAAS;oBACpC,SAAS,EAAE,wBAAS,CAAC,KAAK;iBAC7B,CAAC;gBAEF,OAAO,iCAAY,CAAC,qBAAqB,CAAC,IAAI,CAAC,WAAW,EAAE,yBAAyB,EAAE,GAAG,CAAC,CAAC;YAChG,CAAC,CAAC,CAAC;YACH,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAChC,CAAC;KAAA;CACJ;AA3BD,0DA2BC"}
|
|
@@ -15,8 +15,19 @@ export interface IMeasurements {
|
|
|
15
15
|
water_pot?: number;
|
|
16
16
|
soil_temp?: number;
|
|
17
17
|
}
|
|
18
|
+
export declare enum DateRange {
|
|
19
|
+
TODAY = "today",
|
|
20
|
+
YESTERDAY = "yesterday",
|
|
21
|
+
CURRENTWEEK = "currentWeek",
|
|
22
|
+
PREVIOUSWEEK = "previousWeek",
|
|
23
|
+
CURRENTMONTH = "currentMonth",
|
|
24
|
+
PREVIOUSMONTH = "previousMonth",
|
|
25
|
+
CURRENTYEAR = "currentYear",
|
|
26
|
+
PREVIOUSYEAR = "previousYear"
|
|
27
|
+
}
|
|
18
28
|
export interface IRefreshMeasurementsByIdTask {
|
|
19
29
|
sensorAddr: string;
|
|
30
|
+
dateRange: DateRange;
|
|
20
31
|
}
|
|
21
32
|
export declare const measurements: {
|
|
22
33
|
name: string;
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.measurements = void 0;
|
|
3
|
+
exports.measurements = exports.DateRange = void 0;
|
|
4
|
+
var DateRange;
|
|
5
|
+
(function (DateRange) {
|
|
6
|
+
DateRange["TODAY"] = "today";
|
|
7
|
+
DateRange["YESTERDAY"] = "yesterday";
|
|
8
|
+
DateRange["CURRENTWEEK"] = "currentWeek";
|
|
9
|
+
DateRange["PREVIOUSWEEK"] = "previousWeek";
|
|
10
|
+
DateRange["CURRENTMONTH"] = "currentMonth";
|
|
11
|
+
DateRange["PREVIOUSMONTH"] = "previousMonth";
|
|
12
|
+
DateRange["CURRENTYEAR"] = "currentYear";
|
|
13
|
+
DateRange["PREVIOUSYEAR"] = "previousYear";
|
|
14
|
+
})(DateRange = exports.DateRange || (exports.DateRange = {}));
|
|
4
15
|
exports.measurements = {
|
|
5
16
|
name: "Measurements",
|
|
6
17
|
pgTableName: "measurements",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Measurements.js","sourceRoot":"","sources":["../../src/schema-definitions/Measurements.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Measurements.js","sourceRoot":"","sources":["../../src/schema-definitions/Measurements.ts"],"names":[],"mappings":";;;AAiBA,IAAY,SASX;AATD,WAAY,SAAS;IACjB,4BAAe,CAAA;IACf,oCAAuB,CAAA;IACvB,wCAA2B,CAAA;IAC3B,0CAA6B,CAAA;IAC7B,0CAA6B,CAAA;IAC7B,4CAA+B,CAAA;IAC/B,wCAA2B,CAAA;IAC3B,0CAA6B,CAAA;AACjC,CAAC,EATW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QASpB;AAWY,QAAA,YAAY,GAAG;IACxB,IAAI,EAAE,cAAc;IACpB,WAAW,EAAE,cAAc;CAC9B,CAAC"}
|