[ARVADOS] updated: e32805af332dfdbb973979482e25bc5466236821
git at public.curoverse.com
git at public.curoverse.com
Thu Jul 24 20:41:13 EDT 2014
Summary of changes:
.../controllers/arvados/v1/groups_controller.rb | 79 +++++++++++++++-------
1 file changed, 53 insertions(+), 26 deletions(-)
via e32805af332dfdbb973979482e25bc5466236821 (commit)
from fa92b2cbdac98908040f650b994df0d233380903 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit e32805af332dfdbb973979482e25bc5466236821
Author: Tom Clegg <tom at curoverse.com>
Date: Thu Jul 24 19:03:35 2014 -0400
3235: Split GroupsController#contents logic out to load_searchable_objects.
diff --git a/services/api/app/controllers/arvados/v1/groups_controller.rb b/services/api/app/controllers/arvados/v1/groups_controller.rb
index da82e81..d69cd6c 100644
--- a/services/api/app/controllers/arvados/v1/groups_controller.rb
+++ b/services/api/app/controllers/arvados/v1/groups_controller.rb
@@ -9,9 +9,42 @@ class Arvados::V1::GroupsController < ApplicationController
})
end
+ def render_404_if_no_object
+ if params[:action] == 'contents' and !params[:uuid]
+ # OK!
+ @object = nil
+ else
+ super
+ end
+ end
+
def contents
+ # Set @objects:
+ load_searchable_objects(owner_uuid: @object.andand.uuid, include_linked: params[:include_linked])
+
+ @links = Link.where('link_class=? and tail_uuid=?'\
+ ' and head_uuid in (?)',
+ 'name',
+ @object.uuid,
+ @objects.collect(&:uuid))
+ @object_list = {
+ :kind => "arvados#objectList",
+ :etag => "",
+ :self_link => "",
+ :links => @links.as_api_response(nil),
+ :offset => @offset,
+ :limit => @limit,
+ :items_available => @items_available,
+ :items => @objects.as_api_response(nil)
+ }
+ render json: @object_list
+ end
+
+ protected
+
+ def load_searchable_objects opts
all_objects = []
- all_available = 0
+ @items_available = 0
# Trick apply_where_limit_order_params into applying suitable
# per-table values. *_all are the real ones we'll apply to the
@@ -25,39 +58,33 @@ class Arvados::V1::GroupsController < ApplicationController
Collection,
Human, Specimen, Trait].each do |klass|
@objects = klass.readable_by(*@read_users)
- cond_sql = "#{klass.table_name}.owner_uuid = ?"
- cond_params = [@object.uuid]
- if params[:include_linked]
- 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})"
+ conds = []
+ cond_params = []
+ if opts[:owner_uuid]
+ conds << "#{klass.table_name}.owner_uuid = ?"
+ cond_params << opts[:owner_uuid]
+ end
+ if opts[:include_linked]
+ conds << " 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})"
end
- @objects = @objects.where(cond_sql, *cond_params).order("#{klass.table_name}.uuid")
+ if conds.any?
+ @objects = @objects.where(cond_sql, *cond_params)
+ end
+ @objects = @objects.order("#{klass.table_name}.uuid")
@limit = limit_all - all_objects.count
apply_where_limit_order_params
- items_available = @objects.
+ klass_items_available = @objects.
except(:limit).except(:offset).
count(:id, distinct: true)
- all_available += items_available
- @offset = [@offset - items_available, 0].max
+ @items_available += klass_items_available
+ @offset = [@offset - klass_items_available, 0].max
all_objects += @objects.to_a
end
- @objects = all_objects || []
- @links = Link.where('link_class=? and tail_uuid=?'\
- ' and head_uuid in (?)',
- 'name',
- @object.uuid,
- @objects.collect(&:uuid))
- @object_list = {
- :kind => "arvados#objectList",
- :etag => "",
- :self_link => "",
- :links => @links.as_api_response(nil),
- :offset => offset_all,
- :limit => limit_all,
- :items_available => all_available,
- :items => @objects.as_api_response(nil)
- }
- render json: @object_list
+
+ @objects = all_objects
+ @limit = limit_all
+ @offset = offset_all
end
end
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list