Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter on multiple roadmaps / target versions / fixed_version_id #205

Open
nyrell opened this issue Jun 21, 2018 · 19 comments
Open

Filter on multiple roadmaps / target versions / fixed_version_id #205

nyrell opened this issue Jun 21, 2018 · 19 comments
Assignees
Labels

Comments

@nyrell
Copy link

nyrell commented Jun 21, 2018

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?

@maxtepkeev maxtepkeev self-assigned this Jun 21, 2018
@maxtepkeev
Copy link
Owner

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.

@nyrell
Copy link
Author

nyrell commented Jul 2, 2018

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?

@maxtepkeev
Copy link
Owner

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.

@nyrell
Copy link
Author

nyrell commented Jul 2, 2018

ok, thanks!

@nyrell
Copy link
Author

nyrell commented Jul 2, 2018

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.

@maxtepkeev
Copy link
Owner

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

@nyrell
Copy link
Author

nyrell commented Jul 2, 2018

Great!

@gekmcfh
Copy link

gekmcfh commented Aug 14, 2019

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?

@maxtepkeev
Copy link
Owner

@gekmcfh Unfortunately no.

@cdmb80
Copy link

cdmb80 commented Feb 18, 2021

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

@maxtepkeev
Copy link
Owner

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

@cdmb80
Copy link

cdmb80 commented Feb 18, 2021

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

@maxtepkeev
Copy link
Owner

@cdmb80 issue

@cdmb80
Copy link

cdmb80 commented Feb 18, 2021

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

@maxtepkeev
Copy link
Owner

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

@cdmb80
Copy link

cdmb80 commented Feb 18, 2021

@maxtepkeev thank you

@cdmb80
Copy link

cdmb80 commented Feb 18, 2021

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

@cdmb80
Copy link

cdmb80 commented Feb 22, 2021

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

@maxtepkeev
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants