| |
@@ -4,7 +4,7 @@
|
| |
|
| |
import anytree
|
| |
|
| |
- from coprs import db
|
| |
+ from coprs import db, cache
|
| |
from coprs.helpers import WorkList
|
| |
from coprs.models import Batch, Build
|
| |
from coprs.exceptions import BadRequest
|
| |
@@ -52,13 +52,24 @@
|
| |
Query for all still not-finished batches, order by id ASC
|
| |
"""
|
| |
batches = set()
|
| |
- query = bl.BuildsLogic.processing_builds()
|
| |
+ query = bl.BuildsLogic.processing_builds().filter(Build.batch_id.isnot(None))
|
| |
for build in query.all():
|
| |
if build.batch:
|
| |
batches.add(build.batch)
|
| |
return batches
|
| |
|
| |
@classmethod
|
| |
+ @cache.memoize(timeout=60)
|
| |
+ def pending_batch_count_cached(cls):
|
| |
+ """
|
| |
+ Return the number of currently processed Batch instances (where at least
|
| |
+ one build is not yet fully finished). This is a pretty expensive number
|
| |
+ and yet we show it on every /stats/ page (and on many others) — that's
|
| |
+ why we cache it.
|
| |
+ """
|
| |
+ return len(cls.pending_batches())
|
| |
+
|
| |
+ @classmethod
|
| |
def pending_batch_trees(cls):
|
| |
"""
|
| |
Get all the currently processing batches, together with all the
|
| |