debian-mirror-gitlab/app/assets/javascripts/contributors/stores/getters.js

34 lines
812 B
JavaScript
Raw Normal View History

2019-12-26 22:10:19 +05:30
export const showChart = state => Boolean(!state.loading && state.chartData);
export const parsedData = state => {
2020-04-08 14:13:33 +05:30
const byAuthorEmail = {};
2019-12-26 22:10:19 +05:30
const total = {};
state.chartData.forEach(({ date, author_name, author_email }) => {
total[date] = total[date] ? total[date] + 1 : 1;
2020-04-08 14:13:33 +05:30
const authorData = byAuthorEmail[author_email];
2019-12-26 22:10:19 +05:30
if (!authorData) {
2020-04-08 14:13:33 +05:30
byAuthorEmail[author_email] = {
name: author_name,
2019-12-26 22:10:19 +05:30
commits: 1,
dates: {
[date]: 1,
},
};
} else {
authorData.commits += 1;
authorData.dates[date] = authorData.dates[date] ? authorData.dates[date] + 1 : 1;
}
});
return {
total,
2020-04-08 14:13:33 +05:30
byAuthorEmail,
2019-12-26 22:10:19 +05:30
};
};
// prevent babel-plugin-rewire from generating an invalid default during karma tests
export default () => {};