aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/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
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')
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/__tests__/__snapshots__/utils-test.js.snap119
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/__tests__/utils-test.js12
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/ProjectActivityAnalysesList-test.js.snap53
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/utils.js25
4 files changed, 98 insertions, 111 deletions
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/__tests__/__snapshots__/utils-test.js.snap b/server/sonar-web/src/main/js/apps/projectActivity/__tests__/__snapshots__/utils-test.js.snap
index 52f54d40c25..192b5d66cc8 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/__tests__/__snapshots__/utils-test.js.snap
+++ b/server/sonar-web/src/main/js/apps/projectActivity/__tests__/__snapshots__/utils-test.js.snap
@@ -57,46 +57,47 @@ exports[`getAnalysesByVersionByDay should also filter analysis based on the quer
Array [
Object {
"byDay": Object {
- "2017-4-16": Array [
+ "2017-4-18": Array [
Object {
- "date": 2017-05-16T05:09:59.000Z,
+ "date": 2017-05-18T12:13:07.000Z,
"events": Array [
Object {
- "category": "VERSION",
- "key": "AVyM9oI1HjR_PLDzRciU",
- "name": "1.0",
- },
- Object {
"category": "QUALITY_PROFILE",
- "key": "AVwQF7zXl-nNFgFWOJ3W",
+ "key": "AVxZtC-N7841nF4RNEMJ",
"name": "Changes in \\"Default - SonarSource conventions\\" (Java)",
},
],
- "key": "AVwQF7kwl-nNFgFWOJ3V",
+ "key": "AVxZtCpH7841nF4RNEMI",
},
],
- "2017-4-18": Array [
+ },
+ "key": "AVyM9oI1HjR_PLDzRciU",
+ "version": "1.1",
+ },
+ Object {
+ "byDay": Object {
+ "2017-4-16": Array [
Object {
- "date": 2017-05-18T12:13:07.000Z,
+ "date": 2017-05-16T05:09:59.000Z,
"events": Array [
Object {
+ "category": "VERSION",
+ "key": "AVyM9oI1HjR_PLDzRciU",
+ "name": "1.0",
+ },
+ Object {
"category": "QUALITY_PROFILE",
- "key": "AVxZtC-N7841nF4RNEMJ",
+ "key": "AVwQF7zXl-nNFgFWOJ3W",
"name": "Changes in \\"Default - SonarSource conventions\\" (Java)",
},
],
- "key": "AVxZtCpH7841nF4RNEMI",
+ "key": "AVwQF7kwl-nNFgFWOJ3V",
},
],
},
"key": "AVyM9oI1HjR_PLDzRciU",
"version": "1.0",
},
- Object {
- "byDay": Object {},
- "key": undefined,
- "version": undefined,
- },
]
`;
@@ -107,13 +108,7 @@ Array [
"2017-5-9": Array [
Object {
"date": 2017-06-09T09:12:27.000Z,
- "events": Array [
- Object {
- "category": "VERSION",
- "key": "AVyM9oI1HjR_PLDzRciU",
- "name": "1.1-SNAPSHOT",
- },
- ],
+ "events": Array [],
"key": "AVyM9n3cHjR_PLDzRciT",
},
],
@@ -139,18 +134,24 @@ Array [
"2017-5-9": Array [
Object {
"date": 2017-06-09T09:12:27.000Z,
- "events": Array [],
+ "events": Array [
+ Object {
+ "category": "VERSION",
+ "key": "AVyM9oI1HjR_PLDzRciU",
+ "name": "1.1",
+ },
+ ],
"key": "AVyMjlK1HjR_PLDzRbB9",
},
],
},
"key": "AVyM9oI1HjR_PLDzRciU",
- "version": "1.0",
+ "version": "1.1",
},
Object {
"byDay": Object {},
- "key": undefined,
- "version": undefined,
+ "key": "AVyM9oI1HjR_PLDzRciU",
+ "version": "1.0",
},
]
`;
@@ -162,11 +163,6 @@ Array [
"2017-5-9": Array [
Object {
"date": 2017-06-09T11:06:10.000Z,
- "events": Array [],
- "key": "AVyMjlK1HjR_PLDzRbB9",
- },
- Object {
- "date": 2017-06-09T09:12:27.000Z,
"events": Array [
Object {
"category": "VERSION",
@@ -174,6 +170,11 @@ Array [
"name": "1.1-SNAPSHOT",
},
],
+ "key": "AVyMjlK1HjR_PLDzRbB9",
+ },
+ Object {
+ "date": 2017-06-09T09:12:27.000Z,
+ "events": Array [],
"key": "AVyM9n3cHjR_PLDzRciT",
},
],
@@ -183,24 +184,6 @@ Array [
},
Object {
"byDay": Object {
- "2017-4-16": Array [
- Object {
- "date": 2017-05-16T05:09:59.000Z,
- "events": Array [
- Object {
- "category": "VERSION",
- "key": "AVyM9oI1HjR_PLDzRciU",
- "name": "1.0",
- },
- Object {
- "category": "QUALITY_PROFILE",
- "key": "AVwQF7zXl-nNFgFWOJ3W",
- "name": "Changes in \\"Default - SonarSource conventions\\" (Java)",
- },
- ],
- "key": "AVwQF7kwl-nNFgFWOJ3V",
- },
- ],
"2017-4-18": Array [
Object {
"date": 2017-05-18T12:13:07.000Z,
@@ -222,16 +205,40 @@ Array [
"2017-5-9": Array [
Object {
"date": 2017-06-09T09:12:27.000Z,
- "events": Array [],
+ "events": Array [
+ Object {
+ "category": "VERSION",
+ "key": "AVyM9oI1HjR_PLDzRciU",
+ "name": "1.1",
+ },
+ ],
"key": "AVyMjlK1HjR_PLDzRbB9",
},
],
},
"key": "AVyM9oI1HjR_PLDzRciU",
- "version": "1.0",
+ "version": "1.1",
},
Object {
"byDay": Object {
+ "2017-4-16": Array [
+ Object {
+ "date": 2017-05-16T05:09:59.000Z,
+ "events": Array [
+ Object {
+ "category": "VERSION",
+ "key": "AVyM9oI1HjR_PLDzRciU",
+ "name": "1.0",
+ },
+ Object {
+ "category": "QUALITY_PROFILE",
+ "key": "AVwQF7zXl-nNFgFWOJ3W",
+ "name": "Changes in \\"Default - SonarSource conventions\\" (Java)",
+ },
+ ],
+ "key": "AVwQF7kwl-nNFgFWOJ3V",
+ },
+ ],
"2017-4-9": Array [
Object {
"date": 2017-05-09T10:03:59.000Z,
@@ -240,8 +247,8 @@ Array [
},
],
},
- "key": undefined,
- "version": undefined,
+ "key": "AVyM9oI1HjR_PLDzRciU",
+ "version": "1.0",
},
]
`;
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/__tests__/utils-test.js b/server/sonar-web/src/main/js/apps/projectActivity/__tests__/utils-test.js
index 087184f52b2..7590775840a 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/__tests__/utils-test.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/__tests__/utils-test.js
@@ -21,13 +21,17 @@
import * as utils from '../utils';
const ANALYSES = [
- { key: 'AVyMjlK1HjR_PLDzRbB9', date: new Date('2017-06-09T13:06:10+0200'), events: [] },
{
- key: 'AVyM9n3cHjR_PLDzRciT',
- date: new Date('2017-06-09T11:12:27+0200'),
+ key: 'AVyMjlK1HjR_PLDzRbB9',
+ date: new Date('2017-06-09T13:06:10+0200'),
events: [{ key: 'AVyM9oI1HjR_PLDzRciU', category: 'VERSION', name: '1.1-SNAPSHOT' }]
},
- { key: 'AVyMjlK1HjR_PLDzRbB9', date: new Date('2017-06-09T11:12:27+0200'), events: [] },
+ { key: 'AVyM9n3cHjR_PLDzRciT', date: new Date('2017-06-09T11:12:27+0200'), events: [] },
+ {
+ key: 'AVyMjlK1HjR_PLDzRbB9',
+ date: new Date('2017-06-09T11:12:27+0200'),
+ events: [{ key: 'AVyM9oI1HjR_PLDzRciU', category: 'VERSION', name: '1.1' }]
+ },
{
key: 'AVxZtCpH7841nF4RNEMI',
date: new Date('2017-05-18T14:13:07+0200'),
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/ProjectActivityAnalysesList-test.js.snap b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/ProjectActivityAnalysesList-test.js.snap
index 53dc51ec351..aab488da157 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/ProjectActivityAnalysesList-test.js.snap
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/ProjectActivityAnalysesList-test.js.snap
@@ -185,38 +185,6 @@ exports[`should render correctly 1`] = `
selected={false}
updateSelectedDate={[Function]}
/>
- </ul>
- </li>
- </ul>
- </li>
- <li>
- <div
- className="project-activity-version-badge"
- >
- <span
- className="badge"
- >
- 6.4
- </span>
- </div>
- <ul
- className="project-activity-days-list"
- >
- <li
- className="project-activity-day"
- data-day="Formated.YYYY-MM-DD:2016-9-27"
- >
- <div
- className="project-activity-date"
- >
- <FormattedDate
- date="2016-9-27"
- format="LL"
- />
- </div>
- <ul
- className="project-activity-analyses-list"
- >
<ProjectActivityAnalysis
addCustomEvent={[Function]}
addVersion={[Function]}
@@ -237,6 +205,21 @@ exports[`should render correctly 1`] = `
/>
</ul>
</li>
+ </ul>
+ </li>
+ <li>
+ <div
+ className="project-activity-version-badge"
+ >
+ <span
+ className="badge"
+ >
+ 6.4
+ </span>
+ </div>
+ <ul
+ className="project-activity-days-list"
+ >
<li
className="project-activity-day"
data-day="Formated.YYYY-MM-DD:2016-9-26"
@@ -283,12 +266,6 @@ exports[`should render correctly 1`] = `
/>
</ul>
</li>
- </ul>
- </li>
- <li>
- <ul
- className="project-activity-days-list"
- >
<li
className="project-activity-day"
data-day="Formated.YYYY-MM-DD:2016-9-24"
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);