プロジェクト

全般

プロフィール

Vote #67873

完了

REST issues response with issue count limit and offset

Admin Redmine さんが3年以上前に追加. 3年以上前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
REST API_32
対象バージョン:
開始日:
2010/08/13
期日:
進捗率:

0%

予定工数:
category_id:
32
version_id:
20
issue_org_id:
6140
author_id:
19001
assigned_to_id:
0
comments:
11
status_id:
5
tracker_id:
2
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

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)


journals

now on github
http://github.com/danlin/redmine/commit/f8d2d207d1c60628eb4fdb10402af6eba5dfbe60
--------------------------------------------------------------------------------
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.
--------------------------------------------------------------------------------
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":https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/3217-parsing-an-xml-file-with-multiple-records-and-extra-attributes-besides-type-fails 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:

<pre>
GET /issues.xml

=> <issues type="array">
<issue>
..

GET /issues.xml?page=1

=> <issues type="array" page="1" limit="25" count="562">
<issue>
..
</pre>

Not ideal, but it would be a shame to omit this information just because activeresource doesn't support it.
--------------------------------------------------------------------------------
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

--------------------------------------------------------------------------------
The following attributes were added by r4489 in the response: total_count, offset, limit.

Exemple:

<pre>
<issues total_count="2495" type="array" limit="25" offset="0">
<issue>
...
</issue>
</issues>
</pre>

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:

<pre>
<code class="ruby">
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
</code>
</pre>
--------------------------------------------------------------------------------
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:
<pre>
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
</pre>
- but return the same list of tasks with offset="0" attribute:
<pre>
<?xml version="1.0" encoding="UTF-8"?><issues type="array" limit="25" total_count="50" offset="0">......
</pre>

--------------------------------------------------------------------------------
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:
<pre>
http://academ:3000/issues.xml?project_id=testproject&query_id=2&offset=0&limit=100&key=01d7692c218a74d60d25d8eb5f62874a22ef8599
</pre>

I will update the Wiki page if I have permissions.
--------------------------------------------------------------------------------


related_issues

relates,Closed,4745,Bug in index.xml.builder (issues)

Admin Redmine さんが3年以上前に更新

  • カテゴリREST API_32 にセット
  • 対象バージョン1.1.0_20 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0