Skip to content

Commit cb31858

Browse files
committed
Fix data query parameters.
1 parent fc6f3cf commit cb31858

File tree

1 file changed

+7
-42
lines changed

1 file changed

+7
-42
lines changed

src/shared/hooks/useGetChartData.ts

Lines changed: 7 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -36,56 +36,21 @@ export const useGetChartData = async ({
3636

3737
switch (groupBy) {
3838
case 'node':
39-
metrics = [
40-
{
41-
group_by: ['chart', 'node'],
42-
group_by_label: [],
43-
aggregation: 'sum',
44-
},
45-
{
46-
group_by: ['node'],
47-
group_by_label: [],
48-
aggregation: method,
49-
},
50-
];
39+
metrics = [{ aggregation: method, groupBy: ['node'], group_by_label: [] }];
5140
break;
5241
case 'dimension':
53-
metrics = [
54-
{
55-
group_by: ['dimension'],
56-
group_by_label: [],
57-
aggregation: method,
58-
},
59-
];
42+
metrics = [{ group_by: ['dimension'], group_by_label: [], aggregation: method }];
6043
break;
6144
case 'instance':
62-
metrics = [
63-
{
64-
group_by: ['chart', 'node'],
65-
group_by_label: [],
66-
aggregation: 'sum',
67-
},
68-
];
45+
metrics = [{ aggregation: method, groupBy: ['instance'], group_by_label: [] }];
6946
break;
7047
default:
71-
metrics = [
72-
{
73-
group_by: ['chart'],
74-
group_by_label: groupBy,
75-
aggregation: 'sum',
76-
},
77-
{
78-
group_by: [],
79-
group_by_label: groupBy,
80-
aggregation: 'avg',
81-
},
82-
];
48+
metrics = [{ aggregation: method, groupBy: ['label'], group_by_label: [groupBy] }];
8349
break;
8450
}
8551

86-
const defaultScopeValue = [];
8752
const defaultSelectorValue = ['*'];
88-
const labels = filterBy && filterValue ? [`${filterBy}:${filterValue}`] : null;
53+
const labels = filterBy && filterValue ? [`${filterBy}:${filterValue}`] : [];
8954

9055
return await Post({
9156
path: `/v3/spaces/${spaceId}/rooms/${roomId}/data`,
@@ -97,14 +62,14 @@ export const useGetChartData = async ({
9762
contexts: [contextId],
9863
nodes,
9964
dimensions,
100-
labels: labels || defaultScopeValue,
65+
labels,
10166
},
10267
selectors: {
10368
contexts: ['*'],
10469
nodes: ['*'],
10570
instances: ['*'],
10671
dimensions: dimensions.length ? dimensions : defaultSelectorValue,
107-
labels: labels || defaultSelectorValue,
72+
labels: labels.length ? labels : defaultSelectorValue,
10873
},
10974
aggregations: {
11075
metrics,

0 commit comments

Comments
 (0)