summaryrefslogtreecommitdiffstats
path: root/models/repo_language_stats.go
diff options
context:
space:
mode:
authorLauris BH <lauris@nix.lv>2020-02-14 14:42:30 +0200
committerGitHub <noreply@github.com>2020-02-14 13:42:30 +0100
commita1d796f521919e653f5ceb64d7d361a64cc0139f (patch)
treeee77601af4b21809317b930f5c7232ac52f2a638 /models/repo_language_stats.go
parentff261dafc4845941756a2421acec265663b94e5e (diff)
downloadgitea-a1d796f521919e653f5ceb64d7d361a64cc0139f.tar.gz
gitea-a1d796f521919e653f5ceb64d7d361a64cc0139f.zip
Index code and stats only for non-empty repositories (#10251)
Fix test and switch to unique queue Fix MySQL support when deleting old statistics
Diffstat (limited to 'models/repo_language_stats.go')
-rw-r--r--models/repo_language_stats.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/models/repo_language_stats.go b/models/repo_language_stats.go
index 4c3171e292..bf8f5f59d0 100644
--- a/models/repo_language_stats.go
+++ b/models/repo_language_stats.go
@@ -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
}