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

Retrieving all (closed and open) issues from a specific version #283

Closed
daks opened this issue May 19, 2021 · 2 comments
Closed

Retrieving all (closed and open) issues from a specific version #283

daks opened this issue May 19, 2021 · 2 comments
Assignees
Labels

Comments

@daks
Copy link

daks commented May 19, 2021

Hello,

I recently discovered your library which seems the perfect tool to automate some regular actions on Redmine. I read the documentation and tried several things but I still can't find how to do some specific things which are possible in the web UI.

First, Redmine is version 4.0.5.stable and I initialize the library use with

from redminelib import Redmine

TOKEN = 'XXX'
URL = "https://redmine.example.com"
PROJECT = 'project'
VERSION = 'version'

redmine = Redmine(URL, version='4.0.5.stable', key=TOKEN)

I try to retrieve all (open and closed) issues from a specific version (which is from a specific project)

# OK: filter issues by project_id
redmine.issue.filter(project_id=PROJECT)

# OK: filter issues by project_id and status_id
redmine.issue.filter(project_id=PROJECT,status_id='*')

# KO: filter issues by project_id, status_id and **fixed_version__name**
redmine.issue.filter(project_id=PROJECT,status_id='*',fixed_version__name=VERSION)

# OK: filter issues by project_id, status_id and **fixed_version_id**
redmine.issue.filter(project_id=PROJECT,status_id='*',fixed_version_id=<id>)

Using fixed_version__name does not work but using fixed_version_id does. But I can't find the correct way to retrieve this ID from the VERSION name: there is no option in redmine.version.filter().

Also in other requests I can successfully use the fixed_version__name keyword

project = redmine.project.get(PROJECT)
project.issues.filter(fixed_version__name=VERSION)

So I wonder how I can make this specific request using the library: do I need to loop over each issue to verify its fixed_version?


I have difficulties to understand what is and what is not possible to do with the ORM (I know a little the Django ORM but can't find my way in this one).

For example with the status_id parameter which works in some queries but not others.

# OK
redmine.issue.filter(project_id=PROJECT)

# OK with '*' or 'open' or 'closed'
redmine.issue.filter(project_id=PROJECT,status_id='*')

# KO -> returns nothing
project.issues.filter(status='*')
project.issues.filter(status='closed') 

I thought that the Issue RessourceSet was been used for both redmine.issue and project.issues so I can use the same filter() method. I may misunderstand how it should be used.

Any help would be appreciated.

@maxtepkeev maxtepkeev self-assigned this May 20, 2021
@maxtepkeev
Copy link
Owner

Hi @daks

Apologies for the delay with an answer.

There are 2 entities you're working with in your examples:

  1. ResourceManager - this is what you get when you're doing things like redmine.issue.filter() or redmine.project.all() and so on, i.e. redmine.RESOURCE.OPERATION. So again, redmine.issue returns you a ResourceManager which has different operations i.e. get(), filter(), all() etc. and when you're working with a resource manager - you're working with redmine API directly, so an operation on the ResourceManager supports everything that Redmine API supports, this is why this redmine.issue.filter(project_id=PROJECT,status_id='*',fixed_version_id=<id>) worked for you, because this is a filter operation with filters that Redmine API supports and this filters are partly documented in the Python-Redmine docs. Not all filters are documented in the Python-Redmine docs (there are several issues about it, for example What are all filter operations for issues #57 and Filter on multiple roadmaps / target versions / fixed_version_id #205, but I hope to fix it soon and document everything that is possible to do with redmine filters.

  2. ResourceSet - this is what you get from

project = redmine.project.get(PROJECT)
project.issues # <- this is a ResourceSet

a ResourceSet also has operations like filter() and others which are documented here and this filter() method on a ResourceSet supports resource relationships and a thingy called lookups which all together give you an ability to filter your resourceset, but in Python, and this is a main difference compared to a ResourceManager, i.e. when you're doing filtering on a ResourceManager - you're sending a request to Redmine API and you get those filtered results directly from Redmine and when you're doing filtering on a ResourceSet, all the filtering is done in Python with the help of Python-Redmine magic under the hood and you can only work with filters (filter fields) that already exist in the ResourceSet i.e. was retrieved from Redmine.

I hope this helped a bit, though it might still be a bit confusing, but I am happy to answer more questions if you have any.

@maxtepkeev
Copy link
Owner

Closing this for now, but feel free to reopen if you have any additional questions.

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

2 participants