2020
2121from biothings import config as btconfig
2222from 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
2332from biothings .hub .manager import BaseManager
2433from biothings .utils import mongo
2534from biothings .utils .backend import DocMongoBackend
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)
4352from biothings .utils .loggers import get_logger
4453from biothings .utils .manager import JobManager
4554from 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-
5756logging = 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