2021-03-08 18:12:59 +05:30
|
|
|
export const showChart = (state) => Boolean(!state.loading && state.chartData);
|
2019-12-26 22:10:19 +05:30
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
export const parsedData = (state) => {
|
2020-04-08 14:13:33 +05:30
|
|
|
const byAuthorEmail = {};
|
2019-12-26 22:10:19 +05:30
|
|
|
const total = {};
|
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
state.chartData.forEach(({ date, author_name: name, author_email: email }) => {
|
2019-12-26 22:10:19 +05:30
|
|
|
total[date] = total[date] ? total[date] + 1 : 1;
|
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
const normalizedEmail = email.toLowerCase();
|
2022-05-07 20:08:51 +05:30
|
|
|
const authorData = byAuthorEmail[normalizedEmail];
|
2019-12-26 22:10:19 +05:30
|
|
|
|
|
|
|
if (!authorData) {
|
2022-05-07 20:08:51 +05:30
|
|
|
byAuthorEmail[normalizedEmail] = {
|
2022-08-27 11:52:29 +05:30
|
|
|
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
|
|
|
};
|
|
|
|
};
|