REST issues response with issue count limit and offset
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)
#1 Updated by Daniel Lindenfelser over 7 years ago
#5 Updated by Jean-Philippe Lang about 7 years ago
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.
#6 Updated by Jean-Philippe Lang about 7 years ago
An option would be to include these attributes for "pagination aware" clients that provide a "page" parameter.
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.
#8 Updated by Jean-Philippe Lang about 7 years ago
- 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.
<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
#9 Updated by Alex Last about 7 years ago
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.
#10 Updated by Alex Last about 7 years ago
I see "page" parameter is ignored.
these urls have different "page" value:
- 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">......
#11 Updated by Alex Last about 7 years ago
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:
I will update the Wiki page if I have permissions.