Merge pull request #2329 from opf/fix/query_column_group_by

ensure loading of associated tables when column is only grouped by
pull/2318/head
ulferts 10 years ago
commit 33e6148f17
  1. 12
      app/controllers/api/experimental/work_packages_controller.rb

@ -50,8 +50,7 @@ module Api
def index
@work_packages = current_work_packages
columns = @query.columns.map(&:name) + [:id]
columns << @query.group_by if @query.group_by
columns = all_query_columns(@query)
@column_names, @custom_field_column_ids = separate_columns_by_custom_fields(columns)
@ -101,7 +100,7 @@ module Api
sort_init(@query.sort_criteria.empty? ? [DEFAULT_SORT_ORDER] : @query.sort_criteria)
sort_update(@query.sortable_columns)
results = @query.results include: includes_for_columns(@query.columns.map(&:name)),
results = @query.results include: includes_for_columns(all_query_columns(@query)),
order: sort_clause
work_packages = results.work_packages
@ -114,6 +113,13 @@ module Api
work_packages
end
def all_query_columns(query)
columns = query.columns.map(&:name) + [:id]
columns << query.group_by.to_sym if query.group_by
columns
end
def work_packages_of_ids(ids, column_names)
scope = WorkPackage.visible.includes(includes_for_columns(column_names))

Loading…
Cancel
Save