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>
tokarchuk/v1.17
zeripath 2 years ago committed by GitHub
parent 5283d1ead5
commit 8aaba65eee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      models/issue_stopwatch.go

@ -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 {

Loading…
Cancel
Save