Created
March 13, 2017 12:37
-
-
Save seize-the-dave/24c335d98d7c4eb2fd50a836cd01e8e1 to your computer and use it in GitHub Desktop.
Pull the number of weekly done issues out of JIRA for use as forecasting samples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from jira import JIRA | |
import arrow | |
from datetime import timedelta | |
DONE_ISSUES_QUERY = 'statusCategory = done' | |
SAMPLES=24 | |
jira = JIRA() | |
dates = [] | |
max_results = 50 | |
start_at = 0 | |
while True: | |
issues = jira.search_issues(DONE_ISSUES_QUERY, maxResults=max_results, startAt=start_at) | |
num_issues = len(issues) | |
for issue in issues: | |
dates.append(arrow.get(issue.fields.resolutiondate)) | |
if num_issues < max_results: | |
break | |
else: | |
start_at += max_results | |
end = arrow.get() | |
end = end.replace(hour=0, minute=0, second=0, microsecond=0) | |
end = end - timedelta(days=end.weekday()) | |
curr = end - timedelta(weeks=SAMPLES) | |
while (curr < end): | |
range_min = curr | |
range_max = range_min + timedelta(days=7) | |
count = 0 | |
for date in dates: | |
if date > range_min and date < range_max: | |
count += 1 | |
print(count) | |
curr = range_max |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment