Get total hours by fixed version REST API
Added by MAROUANE YAAGOUB almost 5 years ago
Hello,
I just started using api redmine,
I am looking for can I have total hours by version
like i have version named 'updateredmine':
i wanna get the total hours spent in this version
Version 'updateredmine' | Total hours = 4924.00 hours
Replies (4)
RE: Get total hours by fixed version REST API
-
Added by Mayama Takeshi almost 5 years ago
Hi, you can use python-redmine to simplify Redmine API work.
Here is a basic script that sums the spent hours for each ticket in a version (you must pass project_name and version_name):
https://gist.github.com/MayamaTakeshi/36f563329d1a716ab7313d02ffcf4311
Ex:
$ ./total_hours_per_version.py my_project 1.1.0 total_hours: 7.0
RE: Get total hours by fixed version REST API
-
Added by MAROUANE YAAGOUB almost 5 years ago
Hello Mayama and thanks for your replay
I execute the scripte but i get this message error :
Traceback (most recent call last):
File "total.py", line 28, in <module>
version_id = [x for x in proj.versions if x.name == version][0].id
IndexError: list index out of range
RE: Get total hours by fixed version REST API
-
Added by Mayama Takeshi almost 5 years ago
As I said, that was a basic script and it will work as long as data passed to it is correct.
The error is happening because it tried to find a version by name but the project specified doesn't have such version.
This could happen for example if the version is named 'UpdateRedmine' but you pass 'updateredmine' to it.
Assuming this is the problem, I have adjusted the script to ignore uppercase/lowercase:
https://gist.github.com/MayamaTakeshi/36f563329d1a716ab7313d02ffcf4311
RE: Get total hours by fixed version REST API
-
Added by Go MAEDA almost 5 years ago
Versions API of the upcoming Redmine 4.1.0 supports both estimated_hours and spent_hours attributes (#32242). Stay tuned.