aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/projectActivity/utils.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-web/src/main/js/apps/projectActivity/utils.js')
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/utils.js25
1 files changed, 12 insertions, 13 deletions
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/utils.js b/server/sonar-web/src/main/js/apps/projectActivity/utils.js
index 894fea65128..c38cf0bdbee 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/utils.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/utils.js
@@ -141,10 +141,18 @@ export const getAnalysesByVersionByDay = (
byDay: { [string]: Array<Analysis> }
}> =>
analyses.reduce((acc, analysis) => {
- if (acc.length === 0) {
- acc.push({ version: undefined, key: undefined, byDay: {} });
+ let currentVersion = acc[acc.length - 1];
+ const versionEvent = analysis.events.find(event => event.category === 'VERSION');
+ if (versionEvent) {
+ const newVersion = { version: versionEvent.name, key: versionEvent.key, byDay: {} };
+ if (!currentVersion || Object.keys(currentVersion.byDay).length > 0) {
+ acc.push(newVersion);
+ } else {
+ acc[acc.length - 1] = newVersion;
+ }
+ currentVersion = newVersion;
}
- const currentVersion = acc[acc.length - 1];
+
const day = moment(analysis.date).startOf('day').valueOf().toString();
let matchFilters = true;
@@ -162,15 +170,6 @@ export const getAnalysesByVersionByDay = (
}
currentVersion.byDay[day].push(analysis);
}
-
- const versionEvent = analysis.events.find(event => event.category === 'VERSION');
- if (versionEvent && versionEvent.category === 'VERSION') {
- currentVersion.version = versionEvent.name;
- currentVersion.key = versionEvent.key;
- if (Object.keys(currentVersion.byDay).length > 0) {
- acc.push({ version: undefined, key: undefined, byDay: {} });
- }
- }
return acc;
}, []);
@@ -180,7 +179,7 @@ export const getDisplayedHistoryMetrics = (
): Array<string> => (isCustomGraph(graph) ? customMetrics : GRAPHS_METRICS_DISPLAYED[graph]);
export const getHistoryMetrics = (graph: string, customMetrics: Array<string>): Array<string> =>
- (isCustomGraph(graph) ? customMetrics : GRAPHS_METRICS[graph]);
+ isCustomGraph(graph) ? customMetrics : GRAPHS_METRICS[graph];
const parseGraph = (value?: string): string => {
const graph = parseAsString(value);