1 class Arvados::V1::GroupsController < ApplicationController
3 def self._contents_requires_parameters
4 _index_requires_parameters.
7 type: 'boolean', required: false, default: false
16 # Trick apply_where_limit_order_params into applying suitable
17 # per-table values. *_all are the real ones we'll apply to the
23 [Group, Job, PipelineInstance, PipelineTemplate,
24 Human, Specimen, Trait,
25 Collection].each do |klass|
26 @objects = klass.readable_by(*@read_users)
27 cond_sql = "#{klass.table_name}.owner_uuid = ?"
28 cond_params = [@object.uuid]
29 if params[:include_linked]
30 cond_sql += " OR #{klass.table_name}.uuid IN (SELECT head_uuid FROM links WHERE link_class=#{klass.sanitize 'name'} AND links.tail_uuid=#{klass.sanitize @object.uuid})"
32 @objects = @objects.where(cond_sql, *cond_params).order("#{klass.table_name}.uuid")
33 @limit = limit_all - all_objects.count
34 apply_where_limit_order_params
35 items_available = @objects.
36 except(:limit).except(:offset).
37 count(:id, distinct: true)
38 all_available += items_available
39 @offset = [@offset - items_available, 0].max
41 all_objects += @objects.to_a
43 @objects = all_objects || []
44 @links = Link.where('link_class=? and tail_uuid=?'\
45 ' and head_uuid in (?)',
48 @objects.collect(&:uuid))
50 :kind => "arvados#objectList",
53 :links => @links.as_api_response(nil),
54 :offset => offset_all,
56 :items_available => all_available,
57 :items => @objects.as_api_response(nil)
59 render json: @object_list