Feature #44364 » 0001-Preload-the-associations-rendered-by-the-issues-API-.patch
| app/controllers/issues_controller.rb | ||
|---|---|---|
|
format.api do
|
||
|
@offset, @limit = api_offset_and_limit
|
||
|
@query.column_names = %w(author)
|
||
|
preload = [:tracker, :assigned_to, :category, :fixed_version, :custom_values]
|
||
|
preload << {:attachments => :author} if include_in_api_response?('attachments')
|
||
|
@issue_count = @query.issue_count
|
||
|
@issues = @query.issues(:offset => @offset, :limit => @limit)
|
||
|
@issues = @query.issues(:offset => @offset, :limit => @limit, :preload => preload)
|
||
|
Issue.load_visible_relations(@issues) if include_in_api_response?('relations')
|
||
|
if User.current.allowed_to?(:view_time_entries, nil, :global => true)
|
||
|
Issue.load_visible_spent_hours(@issues)
|
||
| app/models/issue_query.rb | ||
|---|---|---|
|
end
|
||
|
# Returns the issues
|
||
|
# Valid options are :order, :offset, :limit, :include, :conditions
|
||
|
# Valid options are :order, :offset, :limit, :conditions,
|
||
|
# :include, and :preload
|
||
|
def issues(options={})
|
||
|
order_option = [group_by_sort_order, (options[:order] || sort_clause)].flatten.reject(&:blank?)
|
||
|
# The default order of IssueQuery is issues.id DESC(by IssueQuery#default_sort_criteria)
|
||
| ... | ... | |
|
[:tracker, :author, :assigned_to, :fixed_version,
|
||
|
:category, :attachments] & columns.map(&:name)
|
||
|
)
|
||
|
if options[:preload]
|
||
|
scope = scope.preload(options[:preload])
|
||
|
end
|
||
|
if has_custom_field_column?
|
||
|
scope = scope.preload(:custom_values)
|
||
|
end
|
||
- « Previous
- 1
- 2
- Next »