Skip to content

Commit

Permalink
Merge pull request #66 from LoaderB0T/master
Browse files Browse the repository at this point in the history
Fixing per year contribution count
  • Loading branch information
sallar authored Aug 22, 2024
2 parents a49f7c8 + aaeac66 commit a34681f
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,6 @@ function getDateInfo(data: DataStruct, date: string) {
return data.contributions.find(contrib => contrib.date === date);
}

function getContributionCount(graphEntries: GraphEntry[][]) {
return graphEntries.reduce((rowTotal, row) => {
return (
rowTotal +
row.reduce((colTotal, col) => {
return colTotal + (col.info ? col.info.count : 0);
}, 0)
);
}, 0);
}

function drawYear(ctx: CanvasRenderingContext2D, opts: DrawYearOptions) {
const {
year,
Expand Down Expand Up @@ -160,15 +149,11 @@ function drawYear(ctx: CanvasRenderingContext2D, opts: DrawYearOptions) {
);
}
if (!opts.skipHeader) {
const count = new Intl.NumberFormat().format(
getContributionCount(graphEntries)
);

ctx.textBaseline = "hanging";
ctx.fillStyle = theme.text;
ctx.font = `10px '${fontFace}'`;
ctx.fillText(
`${year.year}: ${count} Contribution${year.total === 1 ? "" : "s"}${
`${year.year}: ${year.total} Contribution${year.total === 1 ? "" : "s"}${
thisYear === year.year ? " (so far)" : ""
}`,
offsetX,
Expand Down

0 comments on commit a34681f

Please sign in to comment.