aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/projectActivity/utils.js
diff options
context:
space:
mode:
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>2017-07-31 10:30:55 +0200
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>2017-07-31 13:32:37 +0200
commit2b6e974b64c2de988a5acffbb91fec8f715bacd1 (patch)
tree75bd22f8293f454923b5429c0f78be59a54d84e4 /server/sonar-web/src/main/js/apps/projectActivity/utils.js
parent6c8f9ab97e732110507f39672eb5dd5321afa0fc (diff)
downloadsonarqube-2b6e974b64c2de988a5acffbb91fec8f715bacd1.tar.gz
sonarqube-2b6e974b64c2de988a5acffbb91fec8f715bacd1.zip
SONAR-8550 Update function to group analyses by version
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);