1 class Arvados::V1::GroupsController < ApplicationController
3 def self._contents_requires_parameters
4 _index_requires_parameters.
7 type: 'string', required: false, default: nil
9 # include_linked returns name links, which are obsolete, so
10 # remove it when clients have been migrated.
12 type: 'boolean', required: false, default: false
17 def render_404_if_no_object
18 if params[:action] == 'contents'
26 elsif (@object = User.where(uuid: params[:uuid]).first)
27 # "Home" pseudo-project
39 # include_linked returns name links, which are obsolete, so
40 # remove it when clients have been migrated.
41 load_searchable_objects(owner_uuid: @object.andand.uuid,
42 include_linked: params[:include_linked])
43 sql = 'link_class=? and head_uuid in (?)'
44 sql_params = ['name', @objects.collect(&:uuid)]
46 sql += ' and tail_uuid=?'
47 sql_params << @object.uuid
49 @links = Link.where sql, *sql_params
51 :kind => "arvados#objectList",
54 :links => @links.as_api_response(nil),
57 :items_available => @items_available,
58 :items => @objects.as_api_response(nil)
60 render json: @object_list
65 def load_searchable_objects opts
69 # Trick apply_where_limit_order_params into applying suitable
70 # per-table values. *_all are the real ones we'll apply to the
74 # save the orders from the current request as determined by load_param,
75 # but otherwise discard them because we're going to be getting objects
77 request_orders = @orders.clone
81 Job, PipelineInstance, PipelineTemplate,
83 Human, Specimen, Trait].each do |klass|
84 @objects = klass.readable_by(*@read_users)
86 @objects = @objects.where(group_class: 'project')
91 conds << "#{klass.table_name}.owner_uuid = ?"
92 cond_params << opts[:owner_uuid]
94 cond_sql = '(' + conds.join(') OR (') + ')'
95 @objects = @objects.where(cond_sql, *cond_params)
99 # If the currently requested orders specifically match the table_name for the current klass, apply the order
100 request_order = request_orders && request_orders.find{ |r| r =~ /^#{klass.table_name}\./i }
102 @objects = @objects.order(request_order)
104 # default to created_at desc, ignoring any currently requested ordering because it doesn't apply to this klass
105 @objects = @objects.order("#{klass.table_name}.created_at desc")
108 @limit = limit_all - all_objects.count
109 apply_where_limit_order_params klass
110 klass_items_available = @objects.
111 except(:limit).except(:offset).
112 count(:id, distinct: true)
113 @items_available += klass_items_available
114 @offset = [@offset - klass_items_available, 0].max
116 all_objects += @objects.to_a
119 @objects = all_objects