python-redmine icon indicating copy to clipboard operation
python-redmine copied to clipboard

Filter on multiple roadmaps / target versions / fixed_version_id

Open nyrell opened this issue 6 years ago • 19 comments

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?

nyrell avatar Jun 21 '18 14:06 nyrell

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.

maxtepkeev avatar Jun 21 '18 15:06 maxtepkeev

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?

nyrell avatar Jul 02 '18 12:07 nyrell

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.

maxtepkeev avatar Jul 02 '18 13:07 maxtepkeev

ok, thanks!

nyrell avatar Jul 02 '18 13:07 nyrell

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 avatar Jul 02 '18 14:07 nyrell

@nyrell That's awesome, thanks for sharing. I will add those filter tricks to docs in the near future.

maxtepkeev avatar Jul 02 '18 14:07 maxtepkeev

Great!

nyrell avatar Jul 02 '18 14:07 nyrell

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 avatar Aug 14 '19 13:08 gekmcfh

@gekmcfh Unfortunately no.

maxtepkeev avatar Aug 14 '19 14:08 maxtepkeev

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 avatar Feb 18 '21 09:02 cdmb80

@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 avatar Feb 18 '21 11:02 maxtepkeev

@maxtepkeev Thanks for answering, does this status_id refer to the status of the issue or version?

cdmb80 avatar Feb 18 '21 12:02 cdmb80

@cdmb80 issue

maxtepkeev avatar Feb 18 '21 12:02 maxtepkeev

I need the issues of the currently open versions is it that posible?

cdmb80 avatar Feb 18 '21 12:02 cdmb80

@cdmb80 Yes, add the fixed_version_id parameter (it's actually discussed right in this topic)

maxtepkeev avatar Feb 18 '21 12:02 maxtepkeev

@maxtepkeev thank you

cdmb80 avatar Feb 18 '21 12:02 cdmb80

I couldn't add that filter, if you could help me I would really appreciate it

cdmb80 avatar Feb 18 '21 17:02 cdmb80

Hello, when i apply the filters i get a response like that: <redminelib.resultsets.ResourceSet object with Issue resources> what is that for?

cdmb80 avatar Feb 22 '21 08:02 cdmb80

@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.

maxtepkeev avatar Feb 25 '21 11:02 maxtepkeev