diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2020-06-30 20:01:01 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2020-07-09 19:40:12 +0200 |
| commit | fd3bba535d0200374dad3bd872650a4ceb075cf2 (patch) | |
| tree | b9151e2694710b65cb0e209b192b7fb9d9d1abc3 /dashboard/app/reporting.go | |
| parent | a1aebcca7f3ce0215d6ef3981014d04707c50a60 (diff) | |
dashboard/app: cache per-namespace bug stats
We used to show number of fixed bugs at the top of the main page.
However, now with the button nagivation, "fixed" is shown on every page.
Fetching and processing all bugs on every page would be unwise.
Cache these stats in memcache. It will be useful to show more stats in future.
Diffstat (limited to 'dashboard/app/reporting.go')
| -rw-r--r-- | dashboard/app/reporting.go | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/dashboard/app/reporting.go b/dashboard/app/reporting.go index da3de2232..23703c78b 100644 --- a/dashboard/app/reporting.go +++ b/dashboard/app/reporting.go @@ -44,9 +44,7 @@ func reportingPollBugs(c context.Context, typ string) []*dashapi.BugReport { log.Errorf(c, "%v", err) return nil } - bugs, _, err := loadAllBugs(c, func(query *db.Query) *db.Query { - return query.Filter("Status<", BugStatusFixed) - }) + bugs, _, err := loadOpenBugs(c) if err != nil { log.Errorf(c, "%v", err) return nil @@ -150,9 +148,7 @@ func needReport(c context.Context, typ string, state *ReportingState, bug *Bug) } func reportingPollNotifications(c context.Context, typ string) []*dashapi.BugNotification { - bugs, _, err := loadAllBugs(c, func(query *db.Query) *db.Query { - return query.Filter("Status<", BugStatusFixed) - }) + bugs, _, err := loadOpenBugs(c) if err != nil { log.Errorf(c, "%v", err) return nil @@ -549,6 +545,18 @@ func loadAllBugs(c context.Context, filter func(*db.Query) *db.Query) ([]*Bug, [ return bugs, keys, nil } +func loadNamespaceBugs(c context.Context, ns string) ([]*Bug, []*db.Key, error) { + return loadAllBugs(c, func(query *db.Query) *db.Query { + return query.Filter("Namespace=", ns) + }) +} + +func loadOpenBugs(c context.Context) ([]*Bug, []*db.Key, error) { + return loadAllBugs(c, func(query *db.Query) *db.Query { + return query.Filter("Status<", BugStatusFixed) + }) +} + func foreachBug(c context.Context, filter func(*db.Query) *db.Query, fn func(bug *Bug, key *db.Key) error) error { const batchSize = 1000 var cursor *db.Cursor |
