[ARVADOS] updated: 78447c70f491db25dc99eca60ebcc1b7a5362ec3
git at public.curoverse.com
git at public.curoverse.com
Mon Nov 17 11:47:12 EST 2014
Summary of changes:
apps/workbench/app/controllers/application_controller.rb | 2 --
apps/workbench/app/models/arvados_resource_list.rb | 7 +++++--
apps/workbench/test/unit/arvados_resource_list_test.rb | 11 +++++++++++
3 files changed, 16 insertions(+), 4 deletions(-)
via 78447c70f491db25dc99eca60ebcc1b7a5362ec3 (commit)
from 0adcabd351108e83b630e27c48ce85f2b3cb3e14 (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 78447c70f491db25dc99eca60ebcc1b7a5362ec3
Author: Tom Clegg <tom at curoverse.com>
Date: Mon Nov 17 11:46:30 2014 -0500
4024: Make items_available, result_limit, and result_offset work for empty result sets.
diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb
index e88d38e..3270cfb 100644
--- a/apps/workbench/app/controllers/application_controller.rb
+++ b/apps/workbench/app/controllers/application_controller.rb
@@ -219,8 +219,6 @@ class ApplicationController < ActionController::Base
if !objects
objects = @objects
end
- # result_limit and result_offset won't work until we call #results
- objects.results
if objects.respond_to?(:result_offset) and
objects.respond_to?(:result_limit) and
objects.respond_to?(:items_available)
diff --git a/apps/workbench/app/models/arvados_resource_list.rb b/apps/workbench/app/models/arvados_resource_list.rb
index 6890b87..d989715 100644
--- a/apps/workbench/app/models/arvados_resource_list.rb
+++ b/apps/workbench/app/models/arvados_resource_list.rb
@@ -148,14 +148,17 @@ class ArvadosResourceList
end
def items_available
+ results
@items_available
end
def result_limit
+ results
@result_limit
end
def result_offset
+ results
@result_offset
end
@@ -191,12 +194,12 @@ class ArvadosResourceList
reader_tokens: @reader_tokens)
items = arvados_api_client.unpack_api_response res
- break if items.nil? or not items.any?
-
@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)
+ break if items.nil? or not items.any?
+
item_count += items.size
if items.respond_to?(:offset)
offset = items.offset + items.size
diff --git a/apps/workbench/test/unit/arvados_resource_list_test.rb b/apps/workbench/test/unit/arvados_resource_list_test.rb
index 6494bc5..a3bfbc1 100644
--- a/apps/workbench/test/unit/arvados_resource_list_test.rb
+++ b/apps/workbench/test/unit/arvados_resource_list_test.rb
@@ -80,4 +80,15 @@ class ResourceListTest < ActiveSupport::TestCase
assert_equal c.result_limit, a
end
+ test 'get empty set' do
+ use_token :admin
+ c = Collection.
+ where(owner_uuid: 'doesn-texis-tdoesntexistdoe').
+ fetch_multiple_pages(false)
+ # Important: check c.result_offset before calling c.results here.
+ assert_equal 0, c.result_offset
+ assert_equal 0, c.items_available
+ assert_empty c.results
+ end
+
end
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list