Last active
October 15, 2019 09:55
-
-
Save MayamaTakeshi/36f563329d1a716ab7313d02ffcf4311 to your computer and use it in GitHub Desktop.
Get total hours in redmine project version
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
#!/usr/bin/python | |
import sys | |
from redminelib import Redmine | |
def usage(): | |
app = sys.argv[0] | |
print """ | |
%s project_name project_version | |
%s myproj 1.0.0 | |
""" % (app, app) | |
if len(sys.argv) != 3: | |
print "Invalid number of arguments" | |
usage() | |
sys.exit(1) | |
app, project, version = sys.argv | |
redmine_url = 'YOUR_REDMINE_URL' | |
redmine_key = 'YOUR_REDMINE_KEY' | |
redmine = Redmine(redmine_url, key = redmine_key) | |
proj = redmine.project.get(project) | |
version = version.lower() | |
version_id = [x for x in proj.versions if x.name.lower() == version][0].id | |
total_hours = 0.0 | |
for issue in redmine.issue.all(fixed_version_id = version_id): | |
for tm in redmine.time_entry.all(issue_id = issue.id): | |
total_hours = total_hours + tm.hours | |
print "total_hours: " + str(total_hours) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment