From 8aaba65eeeb7b312a312919c7ccd513acc301f6d Mon Sep 17 00:00:00 2001 From: zeripath Date: Thu, 2 Jun 2022 03:36:46 +0100 Subject: [PATCH] Only return valid stopwatches (#19863) 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 Co-authored-by: techknowlogick --- models/issue_stopwatch.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/issue_stopwatch.go b/models/issue_stopwatch.go index 5b9f5c402d..2cb4a62bd3 100644 --- a/models/issue_stopwatch.go +++ b/models/issue_stopwatch.go @@ -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 {