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, 20 insertions, 5 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 a42c389972c..6ea4c782138 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/utils.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/utils.js
@@ -130,7 +130,8 @@ export const generateSeries = (
};
export const getAnalysesByVersionByDay = (
- analyses: Array<Analysis>
+ analyses: Array<Analysis>,
+ query: Query
): Array<{
version: ?string,
key: ?string,
@@ -142,16 +143,30 @@ export const getAnalysesByVersionByDay = (
}
const currentVersion = acc[acc.length - 1];
const day = moment(analysis.date).startOf('day').valueOf().toString();
- if (!currentVersion.byDay[day]) {
- currentVersion.byDay[day] = [];
+
+ let matchFilters = true;
+ if (query.category || query.from || query.to) {
+ const isAfterFrom = !query.from || analysis.date >= query.from;
+ const isBeforeTo = !query.to || analysis.date <= query.to;
+ const hasSelectedCategoryEvents =
+ !query.category || analysis.events.find(event => event.category === query.category) != null;
+ matchFilters = isAfterFrom && isBeforeTo && hasSelectedCategoryEvents;
+ }
+
+ if (matchFilters) {
+ if (!currentVersion.byDay[day]) {
+ currentVersion.byDay[day] = [];
+ }
+ currentVersion.byDay[day].push(analysis);
}
- 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;
- acc.push({ version: undefined, key: undefined, byDay: {} });
+ if (Object.keys(currentVersion.byDay).length > 0) {
+ acc.push({ version: undefined, key: undefined, byDay: {} });
+ }
}
return acc;
}, []);