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 committed Aug 6, 2024
1 parent 484ad20 commit 32f5fe9
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion jipdate/jipcreate.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,22 @@ def initialize_logger(args):
"customfield_10034": "Share Visibility",
}

def get_sprints(jira, board_id):
# We need to loop over sprints the API returns maximum 50 sprints.
MAX_SPRINTS = 50
sprints_in_board = []
startAt=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=startAt)
sprints_in_board = sprints_in_board + tmp
is_last = tmp.isLast
startAt += MAX_SPRINTS

return sprints_in_board


################################################################################
# Main function
Expand Down Expand Up @@ -225,7 +241,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 32f5fe9

Please sign in to comment.