All files / app/assets/javascripts/contributors/stores getters.js

100% Statements 13/13
100% Branches 8/8
100% Functions 3/3
100% Lines 12/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 317x   2x 2x 2x   2x 9x   9x   9x 4x               5x 5x       2x          
export const showChart = (state) => Boolean(!state.loading && state.chartData);
 
export const parsedData = (state) => {
  const byAuthorEmail = {};
  const total = {};
 
  state.chartData.forEach(({ date, author_name, author_email }) => {
    total[date] = total[date] ? total[date] + 1 : 1;
 
    const authorData = byAuthorEmail[author_email];
 
    if (!authorData) {
      byAuthorEmail[author_email] = {
        name: author_name,
        commits: 1,
        dates: {
          [date]: 1,
        },
      };
    } else {
      authorData.commits += 1;
      authorData.dates[date] = authorData.dates[date] ? authorData.dates[date] + 1 : 1;
    }
  });
 
  return {
    total,
    byAuthorEmail,
  };
};