]> source.dussan.org Git - gitea.git/commitdiff
Only return valid stopwatches (#19863)
authorzeripath <art27@cantab.net>
Thu, 2 Jun 2022 02:36:46 +0000 (03:36 +0100)
committerGitHub <noreply@github.com>
Thu, 2 Jun 2022 02:36:46 +0000 (10:36 +0800)
Looking through the logs of try.gitea.io I am seeing a number of reports
of being unable to APIformat stopwatches because the issueID is 0. These
are invalid StopWatches and they represent a db inconsistency.

This PR simply stops sending them to the eventsource.

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
models/issue_stopwatch.go

index 5b9f5c402dfd8ac0d617a98160f79e694ef1ccd3..2cb4a62bd304859249561e26bcf57572266bd321 100644 (file)
@@ -75,7 +75,7 @@ type UserStopwatch struct {
 // GetUIDsAndNotificationCounts between the two provided times
 func GetUIDsAndStopwatch() ([]*UserStopwatch, error) {
        sws := []*Stopwatch{}
-       if err := db.GetEngine(db.DefaultContext).Find(&sws); err != nil {
+       if err := db.GetEngine(db.DefaultContext).Where("issue_id != 0").Find(&sws); err != nil {
                return nil, err
        }
        if len(sws) == 0 {