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 <art27@cantab.net>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
zeripath 2022-06-02 03:36:46 +01:00 committed by GitHub
parent 5283d1ead5
commit 8aaba65eee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -75,7 +75,7 @@ type UserStopwatch struct {
// GetUIDsAndNotificationCounts between the two provided times // GetUIDsAndNotificationCounts between the two provided times
func GetUIDsAndStopwatch() ([]*UserStopwatch, error) { func GetUIDsAndStopwatch() ([]*UserStopwatch, error) {
sws := []*Stopwatch{} 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 return nil, err
} }
if len(sws) == 0 { if len(sws) == 0 {