1 class Arvados::V1::GroupsController < ApplicationController
3 def self._contents_requires_parameters
4 params = _index_requires_parameters.
7 type: 'string', required: false, default: nil
10 params.delete(:select)
14 def render_404_if_no_object
15 if params[:action] == 'contents'
23 elsif (@object = User.where(uuid: params[:uuid]).first)
24 # "Home" pseudo-project
35 load_searchable_objects
37 :kind => "arvados#objectList",
42 :items_available => @items_available,
43 :items => @objects.as_api_response(nil)
49 def load_searchable_objects
53 # Trick apply_where_limit_order_params into applying suitable
54 # per-table values. *_all are the real ones we'll apply to the
58 # save the orders from the current request as determined by load_param,
59 # but otherwise discard them because we're going to be getting objects
61 request_orders = @orders.clone
64 request_filters = @filters
67 Job, PipelineInstance, PipelineTemplate, ContainerRequest, Workflow,
69 Human, Specimen, Trait]
71 table_names = klasses.map(&:table_name)
72 request_filters.each do |col, op, val|
73 if col.index('.') && !table_names.include?(col.split('.', 2)[0])
74 raise ArgumentError.new("Invalid attribute '#{col}' in filter")
78 klasses.each do |klass|
79 # If the currently requested orders specifically match the
80 # table_name for the current klass, apply that order.
81 # Otherwise, order by recency.
83 request_orders.andand.find { |r| r =~ /^#{klass.table_name}\./i } ||
84 klass.default_orders.join(", ")
88 where_conds[:owner_uuid] = @object.uuid if @object
89 if klass == Collection
90 @select = klass.selectable_attributes - ["manifest_text"]
92 where_conds[:group_class] = "project"
95 @filters = request_filters.map do |col, op, val|
98 elsif (col = col.split('.', 2))[0] == klass.table_name
105 @objects = klass.readable_by(*@read_users).
106 order(request_order).where(where_conds)
107 @limit = limit_all - all_objects.count
108 apply_where_limit_order_params klass
109 klass_object_list = object_list
110 klass_items_available = klass_object_list[:items_available] || 0
111 @items_available += klass_items_available
112 @offset = [@offset - klass_items_available, 0].max
113 all_objects += klass_object_list[:items]
116 @objects = all_objects