Skip to content

Instantly share code, notes, and snippets.

@MayamaTakeshi
Last active October 15, 2019 09:55
Show Gist options
  • Save MayamaTakeshi/36f563329d1a716ab7313d02ffcf4311 to your computer and use it in GitHub Desktop.
Save MayamaTakeshi/36f563329d1a716ab7313d02ffcf4311 to your computer and use it in GitHub Desktop.
Get total hours in redmine project version
#!/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