Skip to content

Commit df09f92

Browse files
authored
Merge pull request #432 from biothings/build-requests
Build Requests Improvement
2 parents de9f047 + a5f7a48 commit df09f92

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

biothings/hub/databuild/builder.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@
2020

2121
from biothings import config as btconfig
2222
from biothings.hub import BUILDER_CATEGORY, UPLOADER_CATEGORY
23+
from biothings.hub.databuild.backend import (
24+
LinkTargetDocMongoBackend,
25+
SourceDocMongoBackend,
26+
TargetDocMongoBackend,
27+
create_backend,
28+
)
29+
from biothings.hub.databuild.buildconfig import AutoBuildConfig
30+
from biothings.hub.databuild.mapper import TransparentMapper
31+
from biothings.hub.dataload.uploader import ResourceNotReady
2332
from biothings.hub.manager import BaseManager
2433
from biothings.utils import mongo
2534
from biothings.utils.backend import DocMongoBackend
@@ -36,24 +45,14 @@
3645
get_source_fullname,
3746
get_src_build,
3847
get_src_build_config,
48+
get_src_db,
3949
get_src_dump,
4050
get_src_master,
41-
get_src_db,
4251
)
4352
from biothings.utils.loggers import get_logger
4453
from biothings.utils.manager import JobManager
4554
from biothings.utils.mongo import doc_feeder, id_feeder
4655

47-
from biothings.hub.databuild.backend import (
48-
LinkTargetDocMongoBackend,
49-
SourceDocMongoBackend,
50-
TargetDocMongoBackend,
51-
create_backend,
52-
)
53-
from biothings.hub.databuild.buildconfig import AutoBuildConfig
54-
from biothings.hub.databuild.mapper import TransparentMapper
55-
from biothings.hub.dataload.uploader import ResourceNotReady
56-
5756
logging = btconfig.logger
5857

5958

@@ -1618,7 +1617,6 @@ def build_info(
16181617
only_archived=True will return archived merges only
16191618
status: will return only successful/failed builds. Can be "success" or "failed"
16201619
"""
1621-
res = {}
16221620
q = self.get_query_for_list_merge(only_archived=only_archived, status=status)
16231621
if id is not None:
16241622
q = {"_id": id}
@@ -1640,6 +1638,12 @@ def build_info(
16401638
b["status"] = "unknown"
16411639
if jobs:
16421640
b["status"] = jobs[-1]["status"]
1641+
stored_total = b.get("_meta", {}).get("stats", {}).get("total")
1642+
if stored_total is not None:
1643+
b["count"] = stored_total
1644+
continue
1645+
1646+
# Fallback for older build docs missing _meta.stats.total.
16431647
try:
16441648
backend = create_backend(b["backend_url"])
16451649
b["count"] = backend.count()

0 commit comments

Comments
 (0)