@hestia-earth/api 0.24.7 → 0.24.9
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.
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { NodeType } from '@hestia-earth/schema';
|
|
2
1
|
import { BaseModel } from '../../db/model.base';
|
|
3
2
|
import { status, pipelineStatus } from '../../files/model/model';
|
|
4
3
|
export declare class Aggregation extends BaseModel {
|
|
4
|
+
folder: string;
|
|
5
5
|
filename: string;
|
|
6
6
|
filepath: string;
|
|
7
7
|
validatedAt?: Date;
|
|
8
8
|
status?: status;
|
|
9
9
|
pipelineStatus?: pipelineStatus;
|
|
10
|
-
readonly nodeType: NodeType;
|
|
11
10
|
readonly productId: string;
|
|
12
11
|
readonly countryId: string;
|
|
13
12
|
readonly startYear: number;
|
|
14
13
|
readonly endYear: number;
|
|
15
14
|
}
|
|
16
|
-
export declare const
|
|
15
|
+
export declare const defaultAggregationPeriod = 20;
|
|
16
|
+
export declare const aggregationFolderFromFilename: (filename: string) => string;
|
|
17
|
+
export declare const parseAggregationValues: (value: string) => Pick<Aggregation, 'productId' | 'countryId' | 'startYear' | 'endYear'>;
|
|
@@ -15,8 +15,8 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
15
15
|
};
|
|
16
16
|
})();
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.
|
|
19
|
-
var
|
|
18
|
+
exports.parseAggregationValues = exports.aggregationFolderFromFilename = exports.defaultAggregationPeriod = exports.Aggregation = void 0;
|
|
19
|
+
var utils_1 = require("@hestia-earth/utils");
|
|
20
20
|
var model_base_1 = require("../../db/model.base");
|
|
21
21
|
var model_1 = require("../../files/model/model");
|
|
22
22
|
var Aggregation = (function (_super) {
|
|
@@ -27,16 +27,25 @@ var Aggregation = (function (_super) {
|
|
|
27
27
|
return Aggregation;
|
|
28
28
|
}(model_base_1.BaseModel));
|
|
29
29
|
exports.Aggregation = Aggregation;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
var
|
|
30
|
+
exports.defaultAggregationPeriod = 20;
|
|
31
|
+
var aggregationFolderFromFilename = function (filename) {
|
|
32
|
+
var name = (0, model_1.filenameWithoutExt)(filename);
|
|
33
|
+
var parts = name.split('-');
|
|
34
|
+
var timestamp = parts.pop();
|
|
35
|
+
return timestamp.length === 8 ? parts.join('-') : name;
|
|
36
|
+
};
|
|
37
|
+
exports.aggregationFolderFromFilename = aggregationFolderFromFilename;
|
|
38
|
+
var parseAggregationValues = function (value) {
|
|
39
|
+
var _a = (0, exports.aggregationFolderFromFilename)(value).split('-'), productId = _a[0], parts = _a.slice(1);
|
|
40
|
+
var countryId = parts.filter(function (v) { return !(0, utils_1.isNumber)(v); }).join('-');
|
|
33
41
|
var endYear = +parts.pop();
|
|
42
|
+
var lastPart = parts.pop();
|
|
43
|
+
var startYear = (0, utils_1.isNumber)(lastPart) ? +lastPart : endYear - exports.defaultAggregationPeriod + 1;
|
|
34
44
|
return {
|
|
35
|
-
nodeType: Object.values(schema_1.NodeType).find(function (v) { return v.toLowerCase() === nodeType.toLowerCase(); }),
|
|
36
45
|
productId: productId,
|
|
37
|
-
countryId:
|
|
38
|
-
startYear:
|
|
46
|
+
countryId: countryId,
|
|
47
|
+
startYear: startYear,
|
|
39
48
|
endYear: endYear
|
|
40
49
|
};
|
|
41
50
|
};
|
|
42
|
-
exports.
|
|
51
|
+
exports.parseAggregationValues = parseAggregationValues;
|