mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-30 11:56:01 +00:00
* fixes App Analytics summary not adjusting to the datetime [UI] #10571 * added comments to the code * updated sum logic, used sumBy method from lodash * addressing comment
This commit is contained in:
parent
6568d0df08
commit
751919e6ca
@ -26,6 +26,7 @@ import {
|
||||
omit,
|
||||
round,
|
||||
sortBy,
|
||||
sumBy,
|
||||
toNumber,
|
||||
} from 'lodash';
|
||||
import moment from 'moment';
|
||||
@ -580,29 +581,32 @@ export const getEntitiesChartSummary = (
|
||||
export const getWebChartSummary = (
|
||||
chartResults: (DataInsightChartResult | undefined)[]
|
||||
) => {
|
||||
const updatedSummary = WEB_SUMMARY_LIST.map((summary) => {
|
||||
const updatedSummary = [];
|
||||
|
||||
for (const summary of WEB_SUMMARY_LIST) {
|
||||
// grab the current chart type
|
||||
const chartData = chartResults.find(
|
||||
(chart) => chart?.chartType === summary.id
|
||||
);
|
||||
// return default summary if chart data is undefined else calculate the latest count for chartType
|
||||
if (isUndefined(chartData)) {
|
||||
return summary;
|
||||
} else {
|
||||
if (chartData.chartType === DataInsightChartType.DailyActiveUsers) {
|
||||
const latestData = last(chartData.data);
|
||||
updatedSummary.push(summary);
|
||||
|
||||
return { ...summary, latest: latestData?.activeUsers ?? 0 };
|
||||
} else {
|
||||
const { total } = getGraphDataByEntityType(
|
||||
chartData.data ?? [],
|
||||
chartData.chartType
|
||||
);
|
||||
|
||||
return { ...summary, latest: total };
|
||||
}
|
||||
continue;
|
||||
}
|
||||
});
|
||||
|
||||
const { chartType, data } = chartData;
|
||||
|
||||
updatedSummary.push({
|
||||
...summary,
|
||||
latest: sumBy(
|
||||
data,
|
||||
chartType === DataInsightChartType.DailyActiveUsers
|
||||
? 'activeUsers'
|
||||
: 'pageViews'
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
return updatedSummary;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user