Skip to content

Commit c89a5e3

Browse files
authored
Merge pull request #94 from newgene/update-builds-api
update builds api: allow status filter
2 parents b7020bf + 14e7df5 commit c89a5e3

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

biothings/hub/databuild/builder.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,10 +1271,17 @@ def archive_merge(self, merge_name):
12711271
"No metadata found for merged collection '%s'" % merge_name)
12721272
self.delete_merged_data(merge_name)
12731273

1274-
def get_query_for_list_merge(self, only_archived):
1274+
def get_query_for_list_merge(self, only_archived, status=None):
12751275
q = {"archived": {"$exists": 0}}
12761276
if only_archived:
12771277
q = {"archived": {"$exists": 1}}
1278+
if status:
1279+
if status == "success":
1280+
q["jobs.status"] = {
1281+
"$not": {"$in": ["failed", "canceled"]}
1282+
}
1283+
elif status in ["failed", "canceled"]:
1284+
q["jobs.status"] = status
12781285
return q
12791286

12801287
def list_merge(self, build_config=None, only_archived=False):
@@ -1634,11 +1641,14 @@ def build_config_info(self):
16341641
res["builder_classes"] = bclasses
16351642
return res
16361643

1637-
def build_info(self,
1638-
id=None,
1639-
conf_name=None,
1640-
fields=None,
1641-
only_archived=False):
1644+
def build_info(
1645+
self,
1646+
id=None,
1647+
conf_name=None,
1648+
fields=None,
1649+
only_archived=False,
1650+
status=None,
1651+
):
16421652
"""
16431653
Return build information given an build _id, or all builds
16441654
if _id is None. "fields" can be passed to select which fields
@@ -1648,9 +1658,10 @@ def build_info(self,
16481658
If id is None, more are filtered:
16491659
- "sources" and some of "build_config"
16501660
only_archived=True will return archived merges only
1661+
status: will return only successful/failed builds. Can be "success" or "failed"
16511662
"""
16521663
res = {}
1653-
q = self.get_query_for_list_merge(only_archived)
1664+
q = self.get_query_for_list_merge(only_archived=only_archived, status=status)
16541665
if id is not None:
16551666
q = {"_id": id}
16561667
else:

0 commit comments

Comments
 (0)