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

project.issues does not return all issues #45

Closed
idokasher opened this issue Aug 22, 2014 · 12 comments
Closed

project.issues does not return all issues #45

idokasher opened this issue Aug 22, 2014 · 12 comments
Assignees
Labels

Comments

@idokasher
Copy link

Hi,

Using Redmine 2.4.2.stable and latest python-redmine, when trying to retrieve all the issues using the following code:

project = redmine.project.get("my_proj")
issues = project.issues

I get a list of 25 unique issues, repeating itself 21 times so that len(issues) = 21 * 25.

Thanks,
Ido.

@idokasher
Copy link
Author

Some more details:
python 3.1.2 is used.

The kwargs dict in Redmine.request seems to hold the right values.
However, the response received from the redmine server has limit set at 25 (instead of 100 and the desired offset).

kwargs just before calling: response = getattr(requests, method)(url, **kwargs).
{'verify': False, 'params': {'project_id': 1, 'limit': 100, 'offset': 0}, 'data': {}, 'auth': ('my_user', 'my_pass'), 'headers': {}}

@maxtepkeev maxtepkeev self-assigned this Sep 2, 2014
@maxtepkeev
Copy link
Owner

Hi!

I can't reproduce it here. Are you using a real Redmine or some fork like ChiliProject ? I'm asking because the problem you described exists exactly in ChiliProject fork.

If you are using a real Redmine, can you also reproduce this problem if you issue a raw request to the API through your browser directly, like http://your-redmine-url/projects/your-project/issues.json?limit=100

Does it return 100 issues or also 25 ?

@idokasher
Copy link
Author

Hey,

I think we use a real Redmine. Can check with our IT guys.
I have made the following change to the code of the request method in the
Redmine class to include the request directly in the URL.
This seems to have bypassed the problem.

def request(self, method, url, headers=None, params=None, data=None):
    """Makes requests to Redmine and returns result in json format"""
    kwargs = dict(self.requests, **{
        'headers': headers or {},
        'params': {},
        # 'params': params or {},
        'data': data or {},
    })

...

    if (params):
        url += "?"
        url += "&".join("%s=%s" % (key, val) for key, val in

params.items())
response = getattr(requests, method)(url, **kwargs)

On Tue, Sep 2, 2014 at 12:57 PM, Max Tepkeev notifications@github.com
wrote:

Hi!

I can't reproduce it here. Are you using a real Redmine or some fork like
ChiliProject ? I'm asking because the problem you described exists exactly
in ChiliProject fork.

If you are using a real Redmine, can you also reproduce this problem if
you issue a raw request to the API through your browser directly, like
http://your-redmine-url/projects/your-project/issues.json?limit=100

Does it return 100 issues or also 25 ?


Reply to this email directly or view it on GitHub
#45 (comment)
.

@maxtepkeev
Copy link
Owner

Hmm... So it looks like it is the requests module that is giving you this problem, what requests version do you use ?

@idokasher
Copy link
Author

2.3.0

On Wed, Sep 3, 2014 at 9:51 AM, Max Tepkeev notifications@github.com
wrote:

Hmm... So it looks like it is the requests module that is giving you this
problem, what requests version do you use ?


Reply to this email directly or view it on GitHub
#45 (comment)
.

@maxtepkeev
Copy link
Owner

I did some more testing and now I think it is not connected with the requests module. I believe it is a bug in the Python 3.1.2 itself, because I managed to reproduce this problem with it, but have no idea where it is coming from. I also tried the latest version from 3.1 branch (3.1.5) and it doesn't have this problem anymore.

Also neither python-redmine nor requests doesn't officially support Python 3.1 branch so there won't be a fix for this from me because it is not the type of bug I can fix (it is not even in my code and looks like it is not in the requests code either). I can only recommend you to upgrade at least to Python 3.1.5, or if you can to Python 3.2 or higher.

@idokasher
Copy link
Author

Sure.

Thanks for looking into it.

On Wed, Sep 3, 2014 at 10:55 AM, Max Tepkeev notifications@github.com
wrote:

I did some more testing and now I think it is not connected with the
requests module. I believe it is a bug in the Python 3.1.2 itself, because
I managed to reproduce this problem with it, but have no idea where it is
coming from. I also tried the latest version from 3.1 branch (3.1.5) and it
doesn't have this problem anymore.

Also neither python-redmine nor requests doesn't officially support Python
3.1 branch so there won't be a fix for this from me because it is not the
type of bug I can fix (it is not even in my code and looks like it is not
in the requests code either). I can only recommend you to upgrade at least
to Python 3.1.5, or if you can to Python 3.2 or higher.


Reply to this email directly or view it on GitHub
#45 (comment)
.

@maxtepkeev
Copy link
Owner

You're welcome.

Also, if for some reason it is impossible for you to upgrade your Python version, you can create your own Redmine class and inherit it from the Redmine class, redefine the request method and use the fix you provided if it works for you.

@bellefab
Copy link

I use Redmine 2.5.3 and it seems that a code like this :

project = redmine.project.get("my_proj")
issues = project.issues

returns the set of 'open' issues in the limit of 100 elements.
As is I was using
redmine.issue.filter(project_id="my_proj",
status_id="*", limit=100)

The messages in the log files seem to say the same thing.
Is that true ?
Is it possible to update the documentation to explicit the 'project.issues' behavior ? I think it is a bit confusing without doc.

Thanks

@maxtepkeev
Copy link
Owner

Hi,

Not exactly, see:

>>> len(redmine.project.get('foobar').issues)
464

>>> len(redmine.issue.filter(project_id='foobar'))
464

>>> len(redmine.issue.filter(project_id='foobar', status_id='open'))
464

>>> len(redmine.issue.filter(project_id='foobar', status_id='closed'))
1243

>>> len(redmine.issue.filter(project_id='foobar', status_id='*'))
1707

So yes, the default behaviour is to return all open issues, absolutely no limiting comes into play unless you ask for it via object slicing syntax, i.e.:

>>> len(redmine.project.get('foobar').issues[:105])
105

@bellefab
Copy link

Humm ... ok, I see.

My problem was that when I used

>>> redmine.project.get('foobar').issues

I though I will get the whole set of issues but I get only the 'open' ones.
That is why I think a comment in the documentation would be helpful.

Anyway, thanks for the quick answer.
And thanks for python-redmine :)

@maxtepkeev
Copy link
Owner

Returning only open issues is the default behaviour of Redmine API itself, but I can add a note in the documentation of course.

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

3 participants