fix incorrect offset

This commit is contained in:
2023-01-30 01:08:48 -08:00
parent 01e529f62a
commit 02cd017227

View File

@@ -138,29 +138,11 @@ func YearFreqFromChan(cc chan types.Commit, year int) types.YearFreq {
yearLength++ yearLength++
} }
freq := make([]int, yearLength) freq := make([]int, yearLength)
data := types.NewDataSet()
for commit := range cc { for commit := range cc {
ts := commit.TimeStamp if commit.TimeStamp.Year() != year {
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 {
continue continue
} }
// this is equivalent to adding len(commits) to the freq total, but freq[commit.TimeStamp.YearDay()-1]++
// it's a stub for later when we do more here
for range v.Commits {
freq[k.YearDay()-1]++
}
} }
return freq return freq
} }
@@ -241,7 +223,7 @@ func (cs CommitSet) ToYearFreq() types.YearFreq {
// this is equivalent to adding len(commits) to the freq total, but // this is equivalent to adding len(commits) to the freq total, but
// it's a stub for later when we do more here // it's a stub for later when we do more here
for range v.Commits { for range v.Commits {
freq[k.YearDay()-1]++ freq[k.YearDay()]++
} }
} }
return freq return freq