Project

General

Profile

Actions

Feature #6140

closed

REST issues response with issue count limit and offset

Added by Daniel Lindenfelser over 13 years ago. Updated over 13 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
REST API
Target version:
Start date:
2010-08-13
Due date:
% Done:

0%

Estimated time:
Resolution:

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


Related issues

Related to Redmine - Defect #4745: Bug in index.xml.builder (issues)ClosedEric Davis2010-02-05

Actions
Actions #2

Updated by J Doe over 13 years ago

  • Assignee set to Eric Davis

isn't this a re-introduction of Defect #4745 ?

Actions #3

Updated by Daniel Lindenfelser over 13 years ago

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.

Actions #4

Updated by Eric Davis over 13 years ago

  • 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

Actions #5

Updated by Jean-Philippe Lang over 13 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.

Actions #6

Updated by Jean-Philippe Lang over 13 years ago

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.

Actions #7

Updated by Alex Last over 13 years ago

I posted a question on related subject to forum, no responses yet:

REST API for Issues returns different results in a Browser and for CURL
http://www.redmine.org/boards/2/topics/19904

Actions #8

Updated by Jean-Philippe Lang over 13 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.

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

Actions #9

Updated by Alex Last over 13 years ago

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.

Actions #10

Updated by Alex Last over 13 years ago

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

Actions #11

Updated by Alex Last over 13 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:

  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.

Actions

Also available in: Atom PDF