Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for fetching all JQL results by way of pagination (fixes #1720) #3304

Merged
merged 2 commits into from
Jan 22, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions redash/query_runner/jql.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ def add_column(self, column, column_type=TYPE_STRING):
def to_json(self):
return json_dumps({'rows': self.rows, 'columns': self.columns.values()})

def merge(self, set):
self.rows = self.rows + set.rows

def parse_issue(issue, field_mapping):
result = OrderedDict()
Expand Down Expand Up @@ -179,6 +181,19 @@ def run_query(self, query, user):
results = parse_count(data)
else:
results = parse_issues(data, field_mapping)
index = data['startAt'] + data['maxResults']

while data['total'] > index:
query['startAt'] = index
response, error = self.get_response(jql_url, params=query)
if error is not None:
return None, error

data = response.json()
index = data['startAt'] + data['maxResults']

addl_results = parse_issues(data, field_mapping)
arikfr marked this conversation as resolved.
Show resolved Hide resolved
results.merge(addl_results)

return results.to_json(), None
except KeyboardInterrupt:
Expand Down