Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Commit

Permalink
handle hot repos year gaps (#97)
Browse files Browse the repository at this point in the history
Signed-off-by: Ayman <[email protected]>
Co-authored-by: Ayman <[email protected]>
  • Loading branch information
khalifapro and enkhalifapro authored Apr 14, 2023
1 parent fca5abc commit 4ed1b2b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cmd/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -3431,15 +3431,20 @@ func (j *DSGit) createCacheFile(cache []CommitCache, path string) error {

func (j *DSGit) createYearHalfCacheFile(cache []CommitCache, path string) error {
nextYearHalfCache := make([]CommitCache, 0)
currentYearCommitsCount := 0
for _, comm := range cache {
comm.FileLocation = path
commitYearHalf := getDateYearHalf(comm.CommitDate)
if comm.CommitDate.Year() == CurrentCacheYear && commitYearHalf == CurrentCacheYearHalf {
cachedCommits[comm.EntityID] = comm
currentYearCommitsCount++
} else {
nextYearHalfCache = append(nextYearHalfCache, comm)
}
}
if currentYearCommitsCount == 0 {
return nil
}
records := [][]string{
{"timestamp", "entity_id", "source_entity_id", "file_location", "hash", "orphaned", "from_dl", "content"},
}
Expand Down Expand Up @@ -3472,13 +3477,14 @@ func (j *DSGit) createYearHalfCacheFile(cache []CommitCache, path string) error
if err != nil {
return err
}

if len(nextYearHalfCache) > 0 {
CurrentCacheYear = nextYearHalfCache[0].CommitDate.Year()
CurrentCacheYearHalf = YearFirstHalf
if nextYearHalfCache[0].CommitDate.Month() > 6 {
CurrentCacheYearHalf = YearSecondHalf
}
updateYearHalf(nextYearHalfCache[0].CommitDate)
//updateYearHalf(nextYearHalfCache[0].CommitDate)
if err = j.createYearHalfCacheFile(nextYearHalfCache, path); err != nil {
return err
}
Expand Down

0 comments on commit 4ed1b2b

Please sign in to comment.