From 527461aa36a9d921e83ab0b719c48607c580ffd6 Mon Sep 17 00:00:00 2001 From: Ashish Kurmi Date: Mon, 27 Apr 2020 13:46:53 -0700 Subject: [PATCH] Adding pagination support in IssueOperations.get_account_open_issues() to retrieve more than 1 MB of data --- hammer/library/ddb_issues.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/hammer/library/ddb_issues.py b/hammer/library/ddb_issues.py index d9ae7de2..586cad25 100755 --- a/hammer/library/ddb_issues.py +++ b/hammer/library/ddb_issues.py @@ -322,10 +322,16 @@ def get_account_open_issues(ddb_table, account_id, issue_class=None): :return: all account open issue """ issues = [] - response = ddb_table.query(KeyConditionExpression=Key('account_id').eq(account_id), - FilterExpression=Attr('status').eq(IssueStatus.Open.value)) - for item in response['Items']: - issues.append(Issue.from_dict(item, issue_class)) + first_iteration = True + response = None + while first_iteration == True or 'LastEvaluatedKey' in response: + response = ddb_table.query(KeyConditionExpression=Key('account_id').eq(account_id), + FilterExpression=Attr('status').eq(IssueStatus.Open.value)) + for item in response['Items']: + issues.append(Issue.from_dict(item, issue_class)) + + if first_iteration == True: + first_iteration = False return issues @staticmethod