Feature #6140
closed
REST issues response with issue count limit and offset
Added by Daniel Lindenfelser about 14 years ago.
Updated over 13 years ago.
Description
Hi i currently build a Redmine Client Application for some Mobile Devices.
I have one Problem.
When i request the issues form REST API there is no way to find out how many issues are currently on the Server.
On the other responses like the html one there are variables with the issue count, limit and page number.
I write this small patch to limit the memory usage and the slowness of query multiple times for different pages to find out how many issues i really have.
This patch add the attributes issue count, limit and current page to the issues node of the REST API response for issues (issues.xml)
Files
- Assignee set to Eric Davis
isn't this a re-introduction of Defect #4745 ?
hmmm ok looks like i have to do this in a other way, but generally the real issue count is really useful for all REST consuming.
- Assignee deleted (
Eric Davis)
I am stepping down from working on Redmine. If someone else is interesting in working on this issue, feel free to reassign it to them.
Eric Davis
Daniel Lindenfelser wrote:
hmmm ok looks like i have to do this in a other way, but generally the real issue count is really useful for all REST consuming.
Indeed, it's a real problem for building a REST client. Unfortunately, adding these attributes will break activeresource clients. The problem was reported to the Rails team here but it's still present in Rails 3.0.
An option would be to include these attributes for "pagination aware" clients that provide a "page" parameter.
Examples:
GET /issues.xml
=> <issues type="array">
<issue>
..
GET /issues.xml?page=1
=> <issues type="array" page="1" limit="25" count="562">
<issue>
..
Not ideal, but it would be a shame to omit this information just because activeresource doesn't support it.
- Tracker changed from Patch to Feature
- Subject changed from REST issues response with issue count limit and page to REST issues response with issue count limit and offset
- Status changed from New to Closed
- Target version set to 1.1.0
The following attributes were added by r4489 in the response: total_count, offset, limit.
Exemple:
<issues total_count="2495" type="array" limit="25" offset="0">
<issue>
...
</issue>
</issues>
The limit is set to 25 by default and can raised to 100. It does not depend on the 'Objects per page options' application setting that applies to UI only.
Note about #4745: using active_resource 2.3.5, renaming the count attribute to total_count seems to solve the problem but it's weird because I don't see anything in the Rails code that would confirm this. Anyway, a compatibility mode was added: these attributes will be omitted if nometa=1 param is present or 'X-Redmine-Nometa' header is set. This can be set this way:
class RedmineResource < ActiveResource::Base
self.site = 'http://localhost:3000/'
self.user = 'xxxx'
self.password = 'xxx'
def self.inherited(child)
child.headers['X-Redmine-Nometa'] = '1'
end
end
class Issue < RedmineResource
end
Jean-Philippe, thanks.
I have a java method getIssues(), which is supposed to load all issues with the given Query ID.
do I have to perform multiple queries to the server to go through pages when I need all issues now?
it's not very convenient...
Is this done to limit memory usage in Ruby?
how do I specify amount of issues per page in my request? This page does not explain it: http://www.redmine.org/wiki/redmine/Rest_Issues
Thanks for your help.
I see "page" parameter is ignored.
these urls have different "page" value:
http://academ:3000/issues.xml?project_id=testproject&query_id=2&page=0&per_page=100&key=01d7692c218a74d60d25d8eb5f62874a22ef8599
http://academ:3000/issues.xml?project_id=testproject&query_id=2&page=1&per_page=100&key=01d7692c218a74d60d25d8eb5f62874a22ef8599
- but return the same list of tasks with offset="0" attribute:
<?xml version="1.0" encoding="UTF-8"?><issues type="array" limit="25" total_count="50" offset="0">......
I had to read the trunk code to find out that "offset" and "limit" parameters must be used instead of "page" and "per_page".
this query works fine:
http://academ:3000/issues.xml?project_id=testproject&query_id=2&offset=0&limit=100&key=01d7692c218a74d60d25d8eb5f62874a22ef8599
I will update the Wiki page if I have permissions.
Also available in: Atom
PDF