X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/13efb6304b9fcbe0fd3b496c751184c7aa1cc4d0..4e32a5d047ab832e7399dedd7b5dd5f8fc364367:/apps/workbench/app/models/arvados_resource_list.rb diff --git a/apps/workbench/app/models/arvados_resource_list.rb b/apps/workbench/app/models/arvados_resource_list.rb index d989715080..35dcde38da 100644 --- a/apps/workbench/app/models/arvados_resource_list.rb +++ b/apps/workbench/app/models/arvados_resource_list.rb @@ -16,6 +16,11 @@ class ArvadosResourceList self end + def distinct(bool=true) + @distinct = bool + self + end + def limit(max_results) if not max_results.nil? and not max_results.is_a? Integer raise ArgumentError("argument to limit() must be an Integer or nil") @@ -79,6 +84,13 @@ class ArvadosResourceList self end + # with_count sets the 'count' parameter to 'exact' or 'none' -- see + # https://doc.arvados.org/api/methods.html#index + def with_count(count_param='exact') + @count = count_param + self + end + def fetch_multiple_pages(f) @fetch_multiple_pages = f self @@ -173,12 +185,17 @@ class ArvadosResourceList api_params = { _method: 'GET' } + api_params[:count] = @count if @count api_params[:where] = @cond if @cond api_params[:eager] = '1' if @eager api_params[:select] = @select if @select api_params[:order] = @orderby_spec if @orderby_spec api_params[:filters] = @filters if @filters - + api_params[:distinct] = @distinct if @distinct + if @fetch_multiple_pages + # Default limit to (effectively) api server's MAX_LIMIT + api_params[:limit] = 2**(0.size*8 - 1) - 1 + end item_count = 0 offset = @offset || 0