Skip to content

Commit

Permalink
fix: use mergedAuthors instead of selectedAuthors in statistics
Browse files Browse the repository at this point in the history
Ref:#237
Time-spent: 0h28m
  • Loading branch information
TBalint2000 committed Jul 24, 2024
1 parent cce5621 commit c965e85
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as React from 'react';
import _ from 'lodash';
import CommitBarChart from './CommitBarChart.tsx';
import styles from '../styles.module.scss';
import {string} from "prop-types";

interface Props {
commits: Commit[];
Expand Down Expand Up @@ -293,18 +294,20 @@ function calculateStatistics(commits: any[], props: Props) {
initialValue[c] = 0;
});
const branches = [...props.branches, 'All branches'];
const authors = [...props.selectedAuthors, 'All authors'];
const authors = [...props.mergedAuthors, 'All authors'];
const statistics = {};

branches.forEach((b) => {
statistics[b] = {};
if (b === 'All branches') {
authors.forEach((a) => {
if (a === 'All authors') {
if (typeof a === 'string' && a === 'All authors') {
statistics[b][a] = calculateRatios(commits, initialValue);
} else {
const filteredForAuthor = commits.filter((c) => c.signature === a);
statistics[b][a] = filteredForAuthor.length === 0 ? {} : calculateRatios(filteredForAuthor, initialValue);
const author = a as Author;
const authorName = author.mainCommitter.substring(0, author.mainCommitter.indexOf('<') - 1);
const filteredForAuthor = commits.filter((c) => author.committers.map((committer) => committer.signature).includes(c.signature));
statistics[b][authorName] = filteredForAuthor.length === 0 ? {} : calculateRatios(filteredForAuthor, initialValue);
}
});
} else {
Expand All @@ -316,8 +319,12 @@ function calculateStatistics(commits: any[], props: Props) {
if (a === 'All authors') {
statistics[b][a] = calculateRatios(filteredForBranch, initialValue);
} else {
const filteredForAuthor = filteredForBranch.filter((c) => c.signature === a);
statistics[b][a] = filteredForAuthor.length === 0 ? {} : calculateRatios(filteredForAuthor, initialValue);
const author = a as Author;
const authorName = author.mainCommitter.substring(0, author.mainCommitter.indexOf('<') - 1);
const filteredForAuthor = filteredForBranch.filter((c) =>
author.committers.map((committer) => committer.signature).includes(c.signature),
);
statistics[b][authorName] = filteredForAuthor.length === 0 ? {} : calculateRatios(filteredForAuthor, initialValue);
}
});
}
Expand Down

0 comments on commit c965e85

Please sign in to comment.