@dative-gpi/foundation-core-services 1.0.189 → 1.0.190-feat-time-normalization-2
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.
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { ref } from "vue";
|
|
2
|
+
|
|
3
|
+
import { uuidv4 } from "@dative-gpi/bones-ui";
|
|
4
|
+
|
|
5
|
+
import { getManyDatas } from "@dative-gpi/foundation-core-services/composables";
|
|
6
|
+
|
|
7
|
+
import { RootMode } from "@dative-gpi/foundation-shared-domain/enums";
|
|
8
|
+
|
|
9
|
+
import type { DataFiltersDTO, DataLeafDTO, AbsoluteProfitsComparisonFilter } from "@dative-gpi/foundation-core-domain/models";
|
|
10
|
+
|
|
11
|
+
export const useAbsoluteProfitsComparison = () => {
|
|
12
|
+
const fetching = ref(false);
|
|
13
|
+
const error = ref<string | null>(null);
|
|
14
|
+
const rawReferenceValue = ref<number | null>(null);
|
|
15
|
+
const rawObservedValue = ref<number | null>(null);
|
|
16
|
+
|
|
17
|
+
const fetch = async (filter: AbsoluteProfitsComparisonFilter) => {
|
|
18
|
+
fetching.value = true;
|
|
19
|
+
|
|
20
|
+
const leaf = {
|
|
21
|
+
correlationId: uuidv4(),
|
|
22
|
+
entitiesIds: filter.entitiesIds,
|
|
23
|
+
entityType: filter.entityType,
|
|
24
|
+
labelTemplate: "",
|
|
25
|
+
aggregateByEntity: 0,
|
|
26
|
+
aggregationTimeStep: undefined,
|
|
27
|
+
duration: 0,
|
|
28
|
+
durationTimeStep: undefined,
|
|
29
|
+
durationDataDefinitionId: undefined,
|
|
30
|
+
durationDataScale: 0,
|
|
31
|
+
dataDefinitions: [
|
|
32
|
+
{
|
|
33
|
+
dataDefinitionId: filter.dataDefinitionId,
|
|
34
|
+
codeTemplate: "",
|
|
35
|
+
label: "",
|
|
36
|
+
unit: filter.unit,
|
|
37
|
+
sort: 0,
|
|
38
|
+
aggregation: filter.aggregation,
|
|
39
|
+
code: ""
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
groupByDataDefinitionIds: [],
|
|
43
|
+
take: 0,
|
|
44
|
+
removeRedundants: false,
|
|
45
|
+
dataCriterias: [],
|
|
46
|
+
timeCriterias: [],
|
|
47
|
+
executionIndex: 0
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
error.value = null;
|
|
51
|
+
rawReferenceValue.value = null;
|
|
52
|
+
rawObservedValue.value = null;
|
|
53
|
+
|
|
54
|
+
try {
|
|
55
|
+
const refFilters: DataFiltersDTO = {
|
|
56
|
+
startDate: filter.referencePeriodStart,
|
|
57
|
+
endDate: filter.referencePeriodEnd,
|
|
58
|
+
timeOffset: filter.timeOffset,
|
|
59
|
+
dateVariables: [],
|
|
60
|
+
mode: RootMode.Leaf,
|
|
61
|
+
leaf: { ...leaf, correlationId: uuidv4() } as DataLeafDTO
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const actFilters: DataFiltersDTO = {
|
|
65
|
+
startDate: filter.observedPeriodStart,
|
|
66
|
+
endDate: filter.observedPeriodEnd,
|
|
67
|
+
timeOffset: filter.timeOffset,
|
|
68
|
+
dateVariables: [],
|
|
69
|
+
mode: RootMode.Leaf,
|
|
70
|
+
leaf: { ...leaf, correlationId: uuidv4() } as DataLeafDTO
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const dataSerieReference = await getManyDatas(refFilters);
|
|
74
|
+
const dataSerieObserved = await getManyDatas(actFilters);
|
|
75
|
+
|
|
76
|
+
const rawRef = dataSerieReference?.[0]?.datas?.[0]?.values?.[0];
|
|
77
|
+
const rawObs = dataSerieObserved?.[0]?.datas?.[0]?.values?.[0];
|
|
78
|
+
|
|
79
|
+
rawReferenceValue.value = rawRef == null ? null : Number(rawRef);
|
|
80
|
+
rawObservedValue.value = rawObs == null ? null : Number(rawObs);
|
|
81
|
+
|
|
82
|
+
} catch (exception: any) {
|
|
83
|
+
error.value = exception.response?.data ?? exception.message;
|
|
84
|
+
} finally {
|
|
85
|
+
fetching.value = false;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
return {
|
|
90
|
+
fetching,
|
|
91
|
+
error,
|
|
92
|
+
rawReferenceValue,
|
|
93
|
+
rawObservedValue,
|
|
94
|
+
fetch,
|
|
95
|
+
};
|
|
96
|
+
};
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"url": "https://github.com/Dative-GPI/foundation-shared-ui.git"
|
|
5
5
|
},
|
|
6
6
|
"sideEffects": false,
|
|
7
|
-
"version": "1.0.
|
|
7
|
+
"version": "1.0.190-feat-time-normalization-2",
|
|
8
8
|
"description": "",
|
|
9
9
|
"publishConfig": {
|
|
10
10
|
"access": "public"
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"author": "",
|
|
14
14
|
"license": "ISC",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@dative-gpi/foundation-core-domain": "1.0.
|
|
16
|
+
"@dative-gpi/foundation-core-domain": "1.0.190-feat-time-normalization-2"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"@dative-gpi/bones-ui": "^1.0.0",
|
|
@@ -21,5 +21,5 @@
|
|
|
21
21
|
"vue": "^3.4.38",
|
|
22
22
|
"vue-router": "^4.3.0"
|
|
23
23
|
},
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "63de5aadeba94007714cb8d44a6a4561e69678a3"
|
|
25
25
|
}
|