python-redmine
python-redmine copied to clipboard
Filter on multiple roadmaps / target versions / fixed_version_id
I am trying to use python-redmine to create a filter that returns all issues that NOT belong to target version A or target version B.
In Redmine I can create this filter easily and it results in the following URL:
https://REDMINE_URL/redmine/projects/PROJECT_ID/issues?utf8=%E2%9C%93
&set_filter=1
&sort=id%3Adesc
&f[]=fixed_version_id
&op[fixed_version_id]=!
&v[fixed_version_id][]=TARGET_VERSION_A_ID
&v[fixed_version_id][]=TARGET_VERSION_B_ID
&f[]=
&c[]=project
&c[]=subject
&c[]=fixed_version
&group_by=
&t[]=
How can I do this using python-redmine? Is it even possible?
I have been experimenting with things like:
redmine.issue.filter(project_id = 1, status_id = 'open', fixed_version_id = '156,134')
but so far I have not been able to get it to accept multiple target versions. It seems negation can be done with "!" like so:
redmine.issue.filter(project_id = 1, status_id = 'open', fixed_version_id = '!156')
Any ideas on how to get this to work?
Hi, don't have much time right now, but you can see all the available operators here. But it looks like there is no such operator as not in
, so in the worst case you'll have to get all versions first, filter unneeded versions and then use in
operator with remaining versions.
Hi, thanks for your help.
I managed to get some results by following your advice:
Get all roadmaps in project:
redmine.project.get(PROJECT_ID).versions
Remove the version IDs belonging to roadmaps that I want to exclude, and then create a filter string on this format:
t+|ID1|ID2|ID3|...|
Then retrieve the issues using: redmine.issue.filter( project_id = PROJECT_ID, status_id = '*', created_on = week_dates_filter_str, fixed_version_id = roadmap_filter_str)
The only remaining problem is that some issues are not assigned to a roadmap, and these are of course not part of the result of my filter above. Is there a way to solve this or do I have to make a separate filter and use "fixed_version_id = '!*'" and then somehow merge my results?
Well, as far as I know you can't apply 2 filters at the same time, but actually it's better to ask Redmine developers at redmine.org since Python-Redmine just passes through this filter strings to Redmine. So I believe yes, you have to make 2 separate requests and then process them separately or create a new ResourceSet object which contains results from both queries.
One optimisation I can recommend you to do is to just use versions = redmine.version.filter(project_id='PROJECT_ID')
to get your versions if you don't need the actual project data, because by using redmine.project.get(PROJECT_ID).versions
you're making 2 separate requests, first is to get the project and second to get all the versions.
ok, thanks!
I just found another solution! It turned out that it is possible to filter for "not in" by writing like this:
fixed_version_id = '!ID1|ID2'
Looks like this will solve my problems. Maybe someone else will find it useful too.
Thanks again.
@nyrell That's awesome, thanks for sharing. I will add those filter tricks to docs in the near future.
Great!
Hi, thanks for your help.
I managed to get some results by following your advice:
Get all roadmaps in project:
redmine.project.get(PROJECT_ID).versions
Remove the version IDs belonging to roadmaps that I want to exclude, and then create a filter string on this format:
t+|ID1|ID2|ID3|...|
Then retrieve the issues using: redmine.issue.filter( project_id = PROJECT_ID, status_id = '*', created_on = week_dates_filter_str, fixed_version_id = roadmap_filter_str)
The only remaining problem is that some issues are not assigned to a roadmap, and these are of course not part of the result of my filter above. Is there a way to solve this or do I have to make a separate filter and use "fixed_version_id = '!*'" and then somehow merge my results?
Hello! Why do you call versions by "roadmaps" ? Please tell is there a way to get true "roadmap" page (http://www.redmine.org/projects/redmine/roadmap) content via api?
@gekmcfh Unfortunately no.
i´m trying to use python-redmine to create a filter that returns all issues of the open versions but i don´t find the way. i just used
redmine.issue.filter(project_id='IP-Leitstand', version_status='open')
can you help me. thanks
@cdmb80 It's all in the docs https://python-redmine.com/resources/issue.html#filter
You've used the wrong parameter, it's not version_status, but status_id.
@maxtepkeev Thanks for answering, does this status_id refer to the status of the issue or version?
@cdmb80 issue
I need the issues of the currently open versions is it that posible?
@cdmb80 Yes, add the fixed_version_id parameter (it's actually discussed right in this topic)
@maxtepkeev thank you
I couldn't add that filter, if you could help me I would really appreciate it
Hello, when i apply the filters i get a response like that: <redminelib.resultsets.ResourceSet object with Issue resources> what is that for?
@cdmb80 It's an iterable of Resource objects (can be empty if response returned no objects). I suggest you read the docs from the very beginning till the very end, because absolutely all the questions you've asked arise only due to not reading the docs.