Skip to content

Commit

Permalink
Check if pageSize is zero, this happens when a IQL Result is empty.
Browse files Browse the repository at this point in the history
Also, Python 3.7 changed the behaviour of generators where one is supposed to just return instead of raising StopIteration. This commit does that.
  • Loading branch information
dstengele committed Aug 19, 2021
1 parent 526c0da commit 24909b3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions jira_insight/insight.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ def search_iql(self, iql=None):

while True:
search_results = self.insight.do_api_request(api_path, params=params)
if search_results["pageSize"] == 0:
return
logging.info(
f'Got page {params["page"]} of {search_results["pageSize"]}'
)
Expand All @@ -294,7 +296,7 @@ def search_iql(self, iql=None):

# Get additional pages if necessary
if params["page"] == search_results["pageSize"]:
raise StopIteration
return

params["page"] += 1

Expand Down Expand Up @@ -396,6 +398,6 @@ def __str__(self):
# Poor man's debugging
insight = Insight(os.environ["INSIGHT_URL"], None, webbrowser_auth=True)
insight_object_schema = InsightObjectSchema(insight, 12)
object_gen = insight_object_schema.search_iql('objectType IN ("Desktop","Laptop","Tablet","Virtuelle Maschine")')
object_gen = insight_object_schema.search_iql('objectType IN ("Desktop","Laptop","Tablet","Virtuelle Maschine") and Seriennummer = 052211303453dfgdfgdfg')

print([i for i in object_gen])
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="jira_insight",
version="0.5.5",
version="0.5.6",
author="Dennis Stengele",
author_email="[email protected]",
description="API client for the Insight app for Jira",
Expand Down

0 comments on commit 24909b3

Please sign in to comment.