From 02cd01722745fc7c2680bae4c53b8538cb608228 Mon Sep 17 00:00:00 2001 From: Tai Groot Date: Mon, 30 Jan 2023 01:08:48 -0800 Subject: [PATCH] fix incorrect offset --- commits/commits.go | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/commits/commits.go b/commits/commits.go index a367c3a..24729ee 100644 --- a/commits/commits.go +++ b/commits/commits.go @@ -138,29 +138,11 @@ func YearFreqFromChan(cc chan types.Commit, year int) types.YearFreq { yearLength++ } freq := make([]int, yearLength) - data := types.NewDataSet() for commit := range cc { - ts := commit.TimeStamp - roundedTS := ts.Round(time.Hour * 24) - wd, ok := data[roundedTS] - if !ok { - wd = types.WorkDay{} - wd.Commits = []types.Commit{} - } - wd.Commits = append(wd.Commits, commit) - wd.Count++ - wd.Day = roundedTS - data[roundedTS] = wd - } - for k, v := range data { - if k.Year() != year { + if commit.TimeStamp.Year() != year { continue } - // this is equivalent to adding len(commits) to the freq total, but - // it's a stub for later when we do more here - for range v.Commits { - freq[k.YearDay()-1]++ - } + freq[commit.TimeStamp.YearDay()-1]++ } return freq } @@ -241,7 +223,7 @@ func (cs CommitSet) ToYearFreq() types.YearFreq { // this is equivalent to adding len(commits) to the freq total, but // it's a stub for later when we do more here for range v.Commits { - freq[k.YearDay()-1]++ + freq[k.YearDay()]++ } } return freq