Skip to content

Commit

Permalink
Fetch-all, get url for finished build, allow disabling of default-filter
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasMatern committed Feb 2, 2022
1 parent ef6d9d7 commit 3f79dbb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
8 changes: 7 additions & 1 deletion pyteamcity/future/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ def finish_date(self):
def agent(self):
return Agent.from_dict(self._data_dict.get('agent'))

@property
def web_url(self):
return self._data_dict['webUrl']

@property
def build_type(self):
return BuildTypeQuerySet(self.teamcity).get(id=self.build_type_id)
Expand Down Expand Up @@ -220,7 +224,7 @@ def filter(self,
since_build=None, since_date=None, status=None,
agent_name=None, personal=None,
canceled=None, failed_to_start=None, running=None,
start=None, count=None, lookup_limit=None):
start=None, count=None, lookup_limit=None, default_filter=None):
if id is not None:
self._add_pred('id', id)
if project is not None:
Expand Down Expand Up @@ -264,6 +268,8 @@ def filter(self,
self._add_pred('count', count)
if lookup_limit is not None:
self._add_pred('lookupLimit', lookup_limit)
if default_filter is not None:
self._add_pred('defaultFilter', default_filter)
return self

def _get_since_date(self, since_date):
Expand Down
23 changes: 22 additions & 1 deletion pyteamcity/future/core/queryset.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def _add_pred(self, name, value):

def _get_url(self, details=False, href=None):
if href is not None:
return 'http://' + self.teamcity.server + href
return self.teamcity.base_url + href

url = self.base_url

Expand Down Expand Up @@ -60,6 +60,27 @@ def _data(self, details=False, href=None):

return self._data_dict

def fetch_all(self):
if self._data_dict:
return
href = None
while href != -1:
# self._locator.page = (start, 50)
page = self._fetch(href=href)
for key, value in page.items():
if key in self._data_dict:
if isinstance(value, list):
self._data_dict[key].extend(value)
elif isinstance(value, int):
self._data_dict[key] += value
else:
self._data_dict[key] = value
href = page.get('nextHref', -1)
for key, value in self._data_dict.items():
if isinstance(value, int):
setattr(self, key, value)
return self

@classmethod
def _from_dict(cls, d, query_set):
return cls._entity_factory.from_dict(d, query_set)
Expand Down

0 comments on commit 3f79dbb

Please sign in to comment.