Welcome to mirror list, hosted at ThFree Co, Russian Federation.

getters.js « stores « contributors « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 79f5c701fb88d6108c1ae252703ed47ec23a15ea (plain)
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
31
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 normalizedEmail = author_email.toLowerCase();
    const authorData = byAuthorEmail[normalizedEmail];

    if (!authorData) {
      byAuthorEmail[normalizedEmail] = {
        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,
  };
};