From 6d8c60258c0b1ac39ab7a7bd82a88f881288bee6 Mon Sep 17 00:00:00 2001 From: Anders Roxell Date: Tue, 6 Aug 2024 09:21:01 +0200 Subject: [PATCH] jipcreate: sprints: find all sprints jira.sprints() has a maxResults of 50, need to support pagination. Signed-off-by: Anders Roxell --- jipdate/jipcreate.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/jipdate/jipcreate.py b/jipdate/jipcreate.py index c9ebcc8..0f72066 100755 --- a/jipdate/jipcreate.py +++ b/jipdate/jipcreate.py @@ -114,6 +114,23 @@ def initialize_logger(args): } +def get_sprints(jira, board_id): + # We need to loop over sprints the API returns maximum 50 sprints. + MAX_SPRINTS = 50 + sprints_in_board = [] + start_at = 0 + is_last = False + + while not is_last: + # We need a tmp variable to read the resultlist metadata. + tmp = jira.sprints(board_id=board_id, maxResults=MAX_SPRINTS, startAt=start_at) + sprints_in_board = sprints_in_board + tmp + is_last = tmp.isLast + start_at += MAX_SPRINTS + + return sprints_in_board + + ################################################################################ # Main function ################################################################################ @@ -225,7 +242,9 @@ def main(): log.debug(f"* {board}") if board.type == "kanban": continue - sprints_in_board = jira.sprints(board_id=board.id) + + sprints_in_board = get_sprints(jira, board.id) + log.debug(f" + Sprints:") for sprint in sprints_in_board: log.debug(f" - {sprint}")