[ARVADOS] updated: 2.1.0-511-g369f45fef

Git user git at public.arvados.org
Thu Mar 25 20:07:44 UTC 2021


Summary of changes:
 .../app/controllers/application_controller.rb        |  2 +-
 .../app/controllers/arvados/v1/groups_controller.rb  | 20 ++++++++++++++++----
 .../api/test/functional/arvados/v1/query_test.rb     | 10 ++++++++++
 services/api/test/integration/groups_test.rb         | 20 ++++++++++++++++++++
 4 files changed, 47 insertions(+), 5 deletions(-)

       via  369f45fefd2b494f0a889ff7cb317c7b78e0220a (commit)
       via  5255e4e80543e92cdae8b1bca74f5b1dc1e1f9b6 (commit)
      from  0d79612df7a9b744ecda195964992d992345c74e (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 369f45fefd2b494f0a889ff7cb317c7b78e0220a
Author: Ward Vandewege <ward at curii.com>
Date:   Thu Mar 25 15:47:35 2021 -0400

    17119: bugfix: the group/contents endpoint should do the right thing
           when 'count: none' and an offset are provided.
    
    Arvados-DCO-1.1-Signed-off-by: Ward Vandewege <ward at curii.com>

diff --git a/services/api/app/controllers/arvados/v1/groups_controller.rb b/services/api/app/controllers/arvados/v1/groups_controller.rb
index 5388e8ffb..a8957de75 100644
--- a/services/api/app/controllers/arvados/v1/groups_controller.rb
+++ b/services/api/app/controllers/arvados/v1/groups_controller.rb
@@ -246,8 +246,6 @@ class Arvados::V1::GroupsController < ApplicationController
 
     seen_last_class = false
     klasses.each do |klass|
-      @offset = 0 if seen_last_class  # reset offset for the new next type being processed
-
       # if current klass is same as params['last_object_class'], mark that fact
       seen_last_class = true if((params['count'].andand.==('none')) and
                                 (params['last_object_class'].nil? or
@@ -296,12 +294,24 @@ class Arvados::V1::GroupsController < ApplicationController
       if params['exclude_home_project']
         @objects = exclude_home @objects, klass
       end
+      if params['count'] == 'none'
+        # The call to object_list below will not populate :items_available in
+        # its response, because count is disabled.  Save @objects length (does
+        # not require another db query) so that @offset (if set) is handled
+        # correctly.
+        countless_items_available = @objects.length
+      end
 
       klass_limit = limit_all - all_objects.count
       @limit = klass_limit
       apply_where_limit_order_params klass
       klass_object_list = object_list(model_class: klass)
-      klass_items_available = klass_object_list[:items_available] || 0
+      if params['count'] != 'none'
+        klass_items_available = klass_object_list[:items_available] || 0
+      else
+        # klass_object_list[:items_available] is not populated
+        klass_items_available = countless_items_available || 0
+      end
       @items_available += klass_items_available
       @offset = [@offset - klass_items_available, 0].max
       all_objects += klass_object_list[:items]
diff --git a/services/api/test/integration/groups_test.rb b/services/api/test/integration/groups_test.rb
index 702176127..aa67166f7 100644
--- a/services/api/test/integration/groups_test.rb
+++ b/services/api/test/integration/groups_test.rb
@@ -177,6 +177,26 @@ class GroupsTest < ActionDispatch::IntegrationTest
     end
     assert_equal true, found_projects.include?(groups(:starred_and_shared_active_user_project).uuid)
   end
+
+  test 'count none works with offset' do
+    first_results = nil
+    (0..10).each do |offset|
+      get "/arvados/v1/groups/contents", params: {
+        id: groups(:aproject).uuid,
+        offset: offset,
+        format: :json,
+        order: :uuid,
+        count: :none,
+      }, headers: auth(:active)
+      assert_response :success
+      assert_nil json_response['items_available']
+      if first_results.nil?
+        first_results = json_response['items']
+      else
+        assert_equal first_results[offset]['uuid'], json_response['items'][0]['uuid']
+      end
+    end
+  end
 end
 
 class NonTransactionalGroupsTest < ActionDispatch::IntegrationTest

commit 5255e4e80543e92cdae8b1bca74f5b1dc1e1f9b6
Author: Ward Vandewege <ward at curii.com>
Date:   Wed Mar 24 17:32:02 2021 -0400

    17119: bugfix: when "count: none" is specified, the group/contents
           endpoint should not return the items_available field.
    
    Arvados-DCO-1.1-Signed-off-by: Ward Vandewege <ward at curii.com>

diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb
index 04449d5f1..04055f848 100644
--- a/apps/workbench/app/controllers/application_controller.rb
+++ b/apps/workbench/app/controllers/application_controller.rb
@@ -239,7 +239,7 @@ class ApplicationController < ActionController::Base
     if objects.respond_to?(:result_offset) and
         objects.respond_to?(:result_limit)
       next_offset = objects.result_offset + objects.result_limit
-      if objects.respond_to?(:items_available) and (next_offset < objects.items_available)
+      if objects.respond_to?(:items_available) and (objects.items_available != nil) and (next_offset < objects.items_available)
         next_offset
       elsif @objects.results.size > 0 and (params[:count] == 'none' or
            (params[:controller] == 'search' and params[:action] == 'choose'))
diff --git a/services/api/app/controllers/arvados/v1/groups_controller.rb b/services/api/app/controllers/arvados/v1/groups_controller.rb
index 6498b7a51..5388e8ffb 100644
--- a/services/api/app/controllers/arvados/v1/groups_controller.rb
+++ b/services/api/app/controllers/arvados/v1/groups_controller.rb
@@ -127,9 +127,11 @@ class Arvados::V1::GroupsController < ApplicationController
       :self_link => "",
       :offset => @offset,
       :limit => @limit,
-      :items_available => @items_available,
       :items => @objects.as_api_response(nil)
     }
+    if params[:count] != 'none'
+      list[:items_available] = @items_available
+    end
     if @extra_included
       list[:included] = @extra_included.as_api_response(nil, {select: @select})
     end
diff --git a/services/api/test/functional/arvados/v1/query_test.rb b/services/api/test/functional/arvados/v1/query_test.rb
index dfa3b7fe7..9bba41857 100644
--- a/services/api/test/functional/arvados/v1/query_test.rb
+++ b/services/api/test/functional/arvados/v1/query_test.rb
@@ -80,6 +80,16 @@ class Arvados::V1::QueryTest < ActionController::TestCase
     refute(json_response.has_key?('items_available'))
   end
 
+  test 'do not count items_available if count=none for group contents endpoint' do
+    @controller = Arvados::V1::GroupsController.new
+    authorize_with :active
+    get :contents, params: {
+      count: 'none',
+    }
+    assert_response(:success)
+    refute(json_response.has_key?('items_available'))
+  end
+
   [{}, {count: nil}, {count: ''}, {count: 'exact'}].each do |params|
     test "count items_available if params=#{params.inspect}" do
       @controller = Arvados::V1::LinksController.new

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list