Safouen
Safouen

Reputation: 133

Get more than 100 issues from redmine

I am trying to get issues from Redmine, but there is a limit of 100 issues. I tried to write a method in the model in order to get all the issues. Here's the whole class:

class IssueResource < ActiveResource::Base
  self.site = 'http://127.0.0.1:5000'
  self.element_name = "issue"
  self.format = ActiveResource::Formats::XmlFormat

  def self.search params
    segment=IssueResource.find(:all,:params=>params)
    issues=segment
    while segment!= []
      segment=IssueResource.find(:all,:params=>params,:having => "id < "+segment.last.id.to_s)
      issues = issues+segment

    end
    return issues

  end
end

As you can see I am trying having and send multiple requests but it does not work.

PS: in the parameter there is always :limit => 100

Upvotes: 3

Views: 2403

Answers (1)

Simone Carletti
Simone Carletti

Reputation: 176352

having is a SQL operator. Here you are not using ActiveRecord, but ActiveResource that performs an HTTP request. For security, a REST API will never allow you (or should never allow you) to provide SQL fragments to be arbitrary executed on the database.

If you read the API documentation for Redmine you will notice there is no having parameter. It's likely you invented it.

What you need to do in order to fetch all the issues, is to use the pagination offset and limit.

Paging example:
GET /issues.xml?offset=0&limit=100
GET /issues.xml?offset=100&limit=100

Upvotes: 3

Related Questions