diff options
author | Grégoire Aubert <gregoire.aubert@sonarsource.com> | 2017-07-10 17:49:11 +0200 |
---|---|---|
committer | Grégoire Aubert <gregoire.aubert@sonarsource.com> | 2017-07-13 14:34:17 +0200 |
commit | d9f1651b8dba7756edf2eb1fce0c0d607e46f05f (patch) | |
tree | 9cf5990469f8cff26c1ab2246e2e4189f883859e /server/sonar-web/src/main/js/apps/projectActivity/utils.js | |
parent | faaee054e871a3aac2167063e411d1373956e082 (diff) | |
download | sonarqube-d9f1651b8dba7756edf2eb1fce0c0d607e46f05f.tar.gz sonarqube-d9f1651b8dba7756edf2eb1fce0c0d607e46f05f.zip |
Fix a bug with the version badges when filtering on an event category
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.js | 25 |
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; }, []); |