Skip to content

Commit

Permalink
jipcreate: sprints: find all sprints
Browse files Browse the repository at this point in the history
jira.sprints() has a maxResults of 50, need to support pagination.

Signed-off-by: Anders Roxell <[email protected]>
  • Loading branch information
roxell authored and JLLinaro committed Aug 6, 2024
1 parent 484ad20 commit 6d8c602
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion jipdate/jipcreate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
################################################################################
Expand Down Expand Up @@ -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}")
Expand Down

0 comments on commit 6d8c602

Please sign in to comment.