forked from NYANDEV/forgejo
Index code and stats only for non-empty repositories (#10251)
Fix test and switch to unique queue Fix MySQL support when deleting old statistics
This commit is contained in:
parent
ff261dafc4
commit
a1d796f521
4 changed files with 19 additions and 7 deletions
|
@ -125,10 +125,19 @@ func (repo *Repository) UpdateLanguageStats(commitID string, stats map[string]fl
|
|||
}
|
||||
}
|
||||
// Delete old languages
|
||||
if _, err := sess.Where("`id` IN (SELECT `id` FROM `language_stat` WHERE `repo_id` = ? AND `commit_id` != ?)", repo.ID, commitID).Delete(&LanguageStat{}); err != nil {
|
||||
return err
|
||||
statsToDelete := make([]int64, 0, len(oldstats))
|
||||
for _, s := range oldstats {
|
||||
if s.CommitID != commitID {
|
||||
statsToDelete = append(statsToDelete, s.ID)
|
||||
}
|
||||
}
|
||||
if len(statsToDelete) > 0 {
|
||||
if _, err := sess.In("`id`", statsToDelete).Delete(&LanguageStat{}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Update indexer status
|
||||
if err = repo.updateIndexerStatus(sess, RepoIndexerTypeStats, commitID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue