Skip to content

Commit

Permalink
GUI billing reports: fix storage reports for storages with the same name
Browse files Browse the repository at this point in the history
  • Loading branch information
rodichenko committed Nov 12, 2024
1 parent 4127fd0 commit 87a55ec
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
10 changes: 6 additions & 4 deletions client/src/components/billing/reports/charts/bar-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ function getMaximum (...values) {
function filterTopData (data, top, dataSample = 'value') {
const sortedData = Object.keys(data || {})
.map((key) => ({
name: key,
key,
name: data[key].name || key,
item: data[key],
value: getItemSampleValue(data[key], dataSample)
}))
Expand Down Expand Up @@ -163,8 +164,8 @@ function BarChart (
datasets.find((o) => !o.isPrevious) ||
datasets[0];
const filteredData = filterTopData(data, top, currentDataset ? currentDataset.sample : 'value');
const groups = filteredData.map(d => d.name);
const displayGroups = groups.map(itemNameFn);
const groupIds = filteredData.map(d => d.key);
const displayGroups = filteredData.map(d => itemNameFn(d.name));
const processedDatasets = datasets.map((dataset) => {
const {
isPrevious = false,
Expand Down Expand Up @@ -323,13 +324,14 @@ function BarChart (
[HighlightTicksPlugin.id]: {
highlightTickFn,
request,
tickValues: groupIds,
axis: 'x-axis'
},
[BarchartDataLabelPlugin.id]: {
valueFormatter
},
[ChartClickPlugin.id]: {
handler: onSelect ? index => onSelect({key: groups[index]}) : undefined,
handler: onSelect ? index => onSelect({key: groupIds[index]}) : undefined,
scaleHandler: onScaleSelect,
axis: 'x-axis'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ const plugin = {
const {
axis = 'x-axis',
highlightTickFn,
request
request,
tickValues
} = configuration;
if (!chart || typeof highlightTickFn !== 'function') {
return;
Expand All @@ -31,7 +32,8 @@ const plugin = {
if (ticks && ticks.length) {
for (const tick of ticks) {
const storage = (request || {}).value;
const value = (storage || {})[tick.value];
const tickValue = tickValues ? tickValues[tick._index] : tick.value;
const value = (storage || {})[tickValue];
tick.major = highlightTickFn(value, tick);
}
}
Expand Down
3 changes: 2 additions & 1 deletion client/src/models/billing/get-grouped-storages.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ export class GetGroupedStorages extends BaseBillingRequest {

(raw && raw.length ? raw : []).forEach(i => {
let name = i.info && i.info.name ? i.info.name : i.groupingInfo.STORAGE;
const id = i.groupingInfo.id || '';
if (name && name !== 'unknown') {
res[name] = {
res[`${name}-${id}`] = {
name,
owner: emptyIfUnknown(i.groupingInfo.owner),
created: emptyIfUnknown(i.groupingInfo.created),
Expand Down

0 comments on commit 87a55ec

Please sign in to comment.