Feature #33526

Add possibility to configure limit used to retrieve objects for an API response

Added by VVD VVD over 1 year ago. Updated over 1 year ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:REST API
Target version:-
Resolution:Duplicate

Description

In file app/controllers/application_controller.rb:

  # Returns offset and limit used to retrieve objects
  # for an API response based on offset, limit and page parameters
  def api_offset_and_limit(options=params)
    if options[:offset].present?
      offset = options[:offset].to_i
      if offset < 0
        offset = 0
      end
    end
    limit = options[:limit].to_i
    if limit < 1
      limit = 25
    elsif limit > 100
      limit = 100
    end
    if offset.nil? && options[:page].present?
      offset = (options[:page].to_i - 1) * limit
      offset = 0 if offset < 0
    end
    offset ||= 0
    [offset, limit]
  end

The value of the limit is hardcoded to 100.
It's very long to get for example 20000 objects - 200 requests in ~3 minutes. But it's faster with hardcoded limit 10000 - ~20 seconds only.

Please, add possibility to configure limit used to retrieve objects for an API response.

Thanks!


Related issues

Duplicates Redmine - Patch #16069: Allow configuration of API limit instead of hardcoding at... New

History

#1 Updated by Mischa The Evil over 1 year ago

  • Duplicates Patch #16069: Allow configuration of API limit instead of hardcoding at 100 added

#2 Updated by Mischa The Evil over 1 year ago

  • Status changed from New to Closed
  • Resolution set to Duplicate

Closing as a duplicate of #16069.

#3 Updated by VVD VVD over 1 year ago

Didn't find it before create this issue.

Also available in: Atom PDF