[ARVADOS] updated: 91f0b180a8474321738577a12250b5a1b8f5bcbc

git at public.curoverse.com git at public.curoverse.com
Wed Nov 12 11:39:45 EST 2014


Summary of changes:
 .../app/controllers/application_controller.rb      |  1 +
 apps/workbench/app/models/arvados_resource_list.rb | 47 +++++++---------------
 .../test/unit/arvados_resource_list_test.rb        | 38 +++++------------
 3 files changed, 24 insertions(+), 62 deletions(-)

       via  91f0b180a8474321738577a12250b5a1b8f5bcbc (commit)
      from  0f9bca457448372de1d15dcd9ed4548c324ff14f (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 91f0b180a8474321738577a12250b5a1b8f5bcbc
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Wed Nov 12 11:39:41 2014 -0500

    3400: Stub out obsolete #links_for and remove result_links and related test.
    Set @result_limit and @result_offset to nil unless @fetch_multiple_pages ==
    false.  Add test for limit > default page size.

diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb
index 27e388b..ff3f5e6 100644
--- a/apps/workbench/app/controllers/application_controller.rb
+++ b/apps/workbench/app/controllers/application_controller.rb
@@ -257,6 +257,7 @@ class ApplicationController < ActionController::Base
       if params[:partial]
         f.json {
           find_objects_for_index if !@objects
+          @objects.fetch_multiple_pages(false)
           render json: {
             content: render_to_string(partial: "choose_rows.html",
                                       formats: [:html]),
diff --git a/apps/workbench/app/models/arvados_resource_list.rb b/apps/workbench/app/models/arvados_resource_list.rb
index 7a6a004..3000aa8 100644
--- a/apps/workbench/app/models/arvados_resource_list.rb
+++ b/apps/workbench/app/models/arvados_resource_list.rb
@@ -97,7 +97,6 @@ class ArvadosResourceList
     @items_available = r.items_available if r.respond_to? :items_available
     @result_limit = r.limit if r.respond_to? :limit
     @result_offset = r.offset if r.respond_to? :offset
-    @result_links = r.links if r.respond_to? :links
     @results
   end
 
@@ -158,33 +157,9 @@ class ArvadosResourceList
     @result_offset
   end
 
-  def result_links
-    @result_links
-  end
-
-  # Return links provided with API response that point to the
-  # specified object, and have the specified link_class. If link_class
-  # is false or omitted, return all links pointing to the specified
-  # object.
+  # Obsolete method retained during api transition.
   def links_for item_or_uuid, link_class=false
-    return [] if !result_links
-    unless @links_for_uuid
-      @links_for_uuid = {}
-      result_links.each do |link|
-        if link.respond_to? :head_uuid
-          @links_for_uuid[link.head_uuid] ||= []
-          @links_for_uuid[link.head_uuid] << link
-        end
-      end
-    end
-    if item_or_uuid.respond_to? :uuid
-      uuid = item_or_uuid.uuid
-    else
-      uuid = item_or_uuid
-    end
-    (@links_for_uuid[uuid] || []).select do |link|
-      link_class == false or link.link_class == link_class
-    end
+    []
   end
 
   protected
@@ -195,13 +170,15 @@ class ArvadosResourceList
     }
     api_params[:where] = @cond if @cond
     api_params[:eager] = '1' if @eager
-    api_params[:limit] = @limit if @limit
     api_params[:select] = @select if @select
     api_params[:order] = @orderby_spec if @orderby_spec
     api_params[:filters] = @filters if @filters
 
+
     item_count = 0
     offset = @offset || 0
+    @result_limit = nil
+    @result_offset = nil
 
     begin
       api_params[:offset] = offset
@@ -214,16 +191,20 @@ class ArvadosResourceList
 
       break if items.nil? or not items.any?
 
-      @items_available = items.items_available if items.respond_to? :items_available
-      @result_limit = items.limit if items.respond_to? :limit
-      @result_offset = items.offset if items.respond_to? :offset
+      @items_available = items.items_available if items.respond_to?(:items_available)
+      @result_limit = items.limit if (@fetch_multiple_pages == false) and items.respond_to?(:limit)
+      @result_offset = items.offset if (@fetch_multiple_pages == false) and items.respond_to?(:offset)
 
       item_count += items.size
-      offset = @result_offset + items.size
+      if items.respond_to?(:offset)
+        offset = items.offset + items.size
+      else
+        offset = item_count
+      end
 
       yield items
 
-      break if @limit.is_a? Integer and item_count >= @limit
+      break if @limit and item_count >= @limit
       break if items.respond_to? :items_available and offset >= items.items_available
     end while @fetch_multiple_pages
     self
diff --git a/apps/workbench/test/unit/arvados_resource_list_test.rb b/apps/workbench/test/unit/arvados_resource_list_test.rb
index d936db0..0955d52 100644
--- a/apps/workbench/test/unit/arvados_resource_list_test.rb
+++ b/apps/workbench/test/unit/arvados_resource_list_test.rb
@@ -8,35 +8,6 @@ class ResourceListTest < ActiveSupport::TestCase
     assert_equal [], results.links_for(api_fixture('users')['active']['uuid'])
   end
 
-  test 'links_for returns all link classes (simulated results)' do
-    project_uuid = api_fixture('groups')['aproject']['uuid']
-    specimen_uuid = api_fixture('specimens')['in_aproject']['uuid']
-    api_response = {
-      kind: 'arvados#specimenList',
-      links: [{kind: 'arvados#link',
-                uuid: 'zzzzz-o0j2j-asdfasdfasdfas1',
-                tail_uuid: project_uuid,
-                head_uuid: specimen_uuid,
-                link_class: 'foo',
-                name: 'Bob'},
-              {kind: 'arvados#link',
-                uuid: 'zzzzz-o0j2j-asdfasdfasdfas2',
-                tail_uuid: project_uuid,
-                head_uuid: specimen_uuid,
-                link_class: nil,
-                name: 'Clydesdale'}],
-      items: [{kind: 'arvados#specimen',
-                uuid: specimen_uuid}]
-    }
-    arl = ArvadosResourceList.new
-    arl.results = ArvadosApiClient.new.unpack_api_response(api_response)
-    assert_equal(['foo', nil],
-                 (arl.
-                  links_for(specimen_uuid).
-                  collect { |x| x.link_class }),
-                 "Expected links_for to return all link_classes")
-  end
-
   test 'get all items by default' do
     use_token :admin
     a = 0
@@ -64,6 +35,15 @@ class ResourceListTest < ActiveSupport::TestCase
     assert_equal 51, a
   end
 
+  test 'get limited items more than default page size' do
+    use_token :admin
+    a = 0
+    Collection.where(owner_uuid: 'zzzzz-j7d0g-0201collections').limit(110).each do
+      a += 1
+    end
+    assert_equal 110, a
+  end
+
   test 'get single page of items' do
     use_token :admin
     a = 0

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list