From: Eric Biagiotti Date: Wed, 28 Aug 2019 13:26:50 +0000 (-0400) Subject: 15583: Adds more with_counts to queries X-Git-Tag: 1.4.1~8 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/888c24424b3c38feee4fbda09ddacd9dfff99540 15583: Adds more with_counts to queries Arvados-DCO-1.1-Signed-off-by: Eric Biagiotti --- diff --git a/apps/workbench/app/controllers/actions_controller.rb b/apps/workbench/app/controllers/actions_controller.rb index b1bbb12267..f769cd33ab 100644 --- a/apps/workbench/app/controllers/actions_controller.rb +++ b/apps/workbench/app/controllers/actions_controller.rb @@ -86,7 +86,7 @@ class ActionsController < ApplicationController end end if resource_class == Collection - dst.manifest_text = Collection.select([:manifest_text]).where(uuid: src.uuid).first.manifest_text + dst.manifest_text = Collection.select([:manifest_text]).where(uuid: src.uuid).with_count("none").first.manifest_text end when :move dst = src @@ -122,7 +122,7 @@ class ActionsController < ApplicationController uuids, source_paths = selected_collection_files params new_coll = Arv::Collection.new - Collection.where(uuid: uuids.uniq). + Collection.where(uuid: uuids.uniq).with_count("none"). select([:uuid, :manifest_text]).each do |coll| src_coll = Arv::Collection.new(coll.manifest_text) src_pathlist = source_paths[coll.uuid] diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb index ab962711b9..a484fb9100 100644 --- a/apps/workbench/app/controllers/application_controller.rb +++ b/apps/workbench/app/controllers/application_controller.rb @@ -497,7 +497,7 @@ class ApplicationController < ActionController::Base def is_starred links = Link.where(tail_uuid: current_user.uuid, head_uuid: @object.uuid, - link_class: 'star') + link_class: 'star').with_count("none") return links.andand.any? end @@ -859,7 +859,7 @@ class ApplicationController < ActionController::Base helper_method :recent_jobs_and_pipelines def recent_jobs_and_pipelines (Job.limit(10) | - PipelineInstance.limit(10)). + PipelineInstance.limit(10).with_count("none")). sort_by do |x| (x.finished_at || x.started_at rescue nil) || x.modified_at || x.created_at end.reverse @@ -867,7 +867,7 @@ class ApplicationController < ActionController::Base helper_method :running_pipelines def running_pipelines - pi = PipelineInstance.order(["started_at asc", "created_at asc"]).filter([["state", "in", ["RunningOnServer", "RunningOnClient"]]]) + pi = PipelineInstance.order(["started_at asc", "created_at asc"]).with_count("none").filter([["state", "in", ["RunningOnServer", "RunningOnClient"]]]) jobs = {} pi.each do |pl| pl.components.each do |k,v| @@ -878,7 +878,7 @@ class ApplicationController < ActionController::Base end if jobs.keys.any? - Job.filter([["uuid", "in", jobs.keys]]).each do |j| + Job.filter([["uuid", "in", jobs.keys]]).with_count("none").each do |j| jobs[j[:uuid]] = j end @@ -901,11 +901,11 @@ class ApplicationController < ActionController::Base procs = {} if PipelineInstance.api_exists?(:index) cols = %w(uuid owner_uuid created_at modified_at pipeline_template_uuid name state started_at finished_at) - pipelines = PipelineInstance.select(cols).limit(lim).order(["created_at desc"]) + pipelines = PipelineInstance.select(cols).limit(lim).order(["created_at desc"]).with_count("none") pipelines.results.each { |pi| procs[pi] = pi.created_at } end - crs = ContainerRequest.limit(lim).order(["created_at desc"]).filter([["requesting_container_uuid", "=", nil]]) + crs = ContainerRequest.limit(lim).with_count("none").order(["created_at desc"]).filter([["requesting_container_uuid", "=", nil]]) crs.results.each { |c| procs[c] = c.created_at } Hash[procs.sort_by {|key, value| value}].keys.reverse.first(lim) @@ -913,9 +913,9 @@ class ApplicationController < ActionController::Base helper_method :recent_collections def recent_collections lim - c = Collection.limit(lim).order(["modified_at desc"]).results + c = Collection.limit(lim).with_count("none").order(["modified_at desc"]).results own = {} - Group.filter([["uuid", "in", c.map(&:owner_uuid)]]).each do |g| + Group.filter([["uuid", "in", c.map(&:owner_uuid)]]).with_count("none").each do |g| own[g[:uuid]] = g end {collections: c, owners: own} @@ -926,9 +926,9 @@ class ApplicationController < ActionController::Base return if @starred_projects links = Link.filter([['tail_uuid', '=', user.uuid], ['link_class', '=', 'star'], - ['head_uuid', 'is_a', 'arvados#group']]).select(%w(head_uuid)) + ['head_uuid', 'is_a', 'arvados#group']]).with_count("none").select(%w(head_uuid)) uuids = links.collect { |x| x.head_uuid } - starred_projects = Group.filter([['uuid', 'in', uuids]]).order('name') + starred_projects = Group.filter([['uuid', 'in', uuids]]).order('name').with_count("none") @starred_projects = starred_projects.results end @@ -1081,7 +1081,7 @@ class ApplicationController < ActionController::Base end # TODO: make sure we get every page of results from API server - Link.filter([['head_uuid', 'in', uuids]]).each do |link| + Link.filter([['head_uuid', 'in', uuids]]).with_count("none").each do |link| @all_links_for[link.head_uuid] << link end @all_links_for @@ -1134,7 +1134,7 @@ class ApplicationController < ActionController::Base end # TODO: make sure we get every page of results from API server - Collection.where(uuid: uuids).each do |collection| + Collection.where(uuid: uuids).with_count("none").each do |collection| @all_collections_for[collection.uuid] << collection end @all_collections_for @@ -1184,7 +1184,7 @@ class ApplicationController < ActionController::Base end # TODO: make sure we get every page of results from API server - Collection.where(uuid: uuids).each do |collection| + Collection.where(uuid: uuids).with_count("none").each do |collection| @all_log_collections_for[collection.uuid] << collection end @all_log_collections_for @@ -1217,7 +1217,7 @@ class ApplicationController < ActionController::Base @all_pdhs_for[x] = [] end - Collection.select(%w(portable_data_hash)).where(portable_data_hash: pdhs).distinct().each do |collection| + Collection.select(%w(portable_data_hash)).where(portable_data_hash: pdhs).distinct().with_count("none").each do |collection| @all_pdhs_for[collection.portable_data_hash] << collection end @all_pdhs_for @@ -1288,7 +1288,7 @@ class ApplicationController < ActionController::Base end unless link_uuids.empty? - Link.select([:head_uuid]).where(uuid: link_uuids).each do |link| + Link.select([:head_uuid]).where(uuid: link_uuids).with_count("none").each do |link| if ArvadosBase::resource_class_for_uuid(link.head_uuid) == Collection coll_ids << link.head_uuid end @@ -1311,7 +1311,7 @@ class ApplicationController < ActionController::Base end unless pdhs.empty? - Collection.where(portable_data_hash: pdhs.uniq). + Collection.where(portable_data_hash: pdhs.uniq).with_count("none"). select([:uuid, :portable_data_hash]).each do |coll| unless source_paths[coll.portable_data_hash].empty? uuids << coll.uuid diff --git a/apps/workbench/app/controllers/collections_controller.rb b/apps/workbench/app/controllers/collections_controller.rb index 8d7e6ee332..64ae352133 100644 --- a/apps/workbench/app/controllers/collections_controller.rb +++ b/apps/workbench/app/controllers/collections_controller.rb @@ -36,7 +36,7 @@ class CollectionsController < ApplicationController ['link_class', '=', 'resources'], ['name', '=', 'wants'], ['tail_uuid', '=', current_user.uuid], - ['head_uuid', '=', @object.uuid]]) + ['head_uuid', '=', @object.uuid]]).with_count("none") logger.debug persist_links.inspect else return unprocessable "Invalid value #{value.inspect}" @@ -65,7 +65,7 @@ class CollectionsController < ApplicationController @select ||= Collection.columns.map(&:name) base_search = Collection.select(@select) if params[:search].andand.length.andand > 0 - tags = Link.where(any: ['contains', params[:search]]) + tags = Link.where(any: ['contains', params[:search]]).with_count("none") @objects = (base_search.where(uuid: tags.collect(&:head_uuid)) | base_search.where(any: ['contains', params[:search]])). uniq { |c| c.uuid } @@ -84,7 +84,7 @@ class CollectionsController < ApplicationController @objects = base_search.limit(limit).offset(offset) end - @links = Link.where(head_uuid: @objects.collect(&:uuid)) + @links = Link.where(head_uuid: @objects.collect(&:uuid)).with_count("none") @collection_info = {} @objects.each do |c| @collection_info[c.uuid] = { @@ -196,19 +196,19 @@ class CollectionsController < ApplicationController else if Job.api_exists?(:index) jobs_with = lambda do |conds| - Job.limit(RELATION_LIMIT).where(conds) + Job.limit(RELATION_LIMIT).with_count("none").where(conds) .results.sort_by { |j| j.finished_at || j.created_at } end @output_of = jobs_with.call(output: @object.portable_data_hash) @log_of = jobs_with.call(log: @object.portable_data_hash) end - @project_links = Link.limit(RELATION_LIMIT).order("modified_at DESC") + @project_links = Link.limit(RELATION_LIMIT).with_count("none").order("modified_at DESC") .where(head_uuid: @object.uuid, link_class: 'name').results - project_hash = Group.where(uuid: @project_links.map(&:tail_uuid)).to_hash + project_hash = Group.where(uuid: @project_links.map(&:tail_uuid)).with_count("none").to_hash @projects = project_hash.values - @permissions = Link.limit(RELATION_LIMIT).order("modified_at DESC") + @permissions = Link.limit(RELATION_LIMIT).with_count("none").order("modified_at DESC") .where(head_uuid: @object.uuid, link_class: 'permission', name: 'can_read').results @search_sharing = search_scopes diff --git a/apps/workbench/app/controllers/container_requests_controller.rb b/apps/workbench/app/controllers/container_requests_controller.rb index d5627076f5..0a1af36193 100644 --- a/apps/workbench/app/controllers/container_requests_controller.rb +++ b/apps/workbench/app/controllers/container_requests_controller.rb @@ -20,7 +20,7 @@ class ContainerRequestsController < ApplicationController # Search for child CRs if cr[:container_uuid] - child_crs = ContainerRequest.where(requesting_container_uuid: cr[:container_uuid]) + child_crs = ContainerRequest.where(requesting_container_uuid: cr[:container_uuid]).with_count("none") child_crs.each do |child| nodes[child[:uuid]] = child @@ -35,14 +35,14 @@ class ContainerRequestsController < ApplicationController # Batch requests to get all related collections # First fetch output collections by UUID. - Collection.filter([['uuid', 'in', col_uuids.uniq]]).each do |c| + Collection.filter([['uuid', 'in', col_uuids.uniq]]).with_count("none").each do |c| output_cols[c[:uuid]] = c output_pdhs << c[:portable_data_hash] end # Then, get only input collections by PDH. There could be more than one collection # per PDH: the number of collections is used on the collection node label. Collection.filter( - [['portable_data_hash', 'in', col_pdhs - output_pdhs]]).each do |c| + [['portable_data_hash', 'in', col_pdhs - output_pdhs]]).with_count("none").each do |c| if input_cols[c[:portable_data_hash]] input_cols[c[:portable_data_hash]] << c else @@ -78,7 +78,7 @@ class ContainerRequestsController < ApplicationController def cancel if @object.container_uuid - c = Container.select(['state']).where(uuid: @object.container_uuid).first + c = Container.select(['state']).where(uuid: @object.container_uuid).with_count("none").first if c && c.state != 'Running' # If the container hasn't started yet, setting priority=0 # leaves our request in "Committed" state and doesn't cancel diff --git a/apps/workbench/app/controllers/groups_controller.rb b/apps/workbench/app/controllers/groups_controller.rb index aa78feb9a0..5da55be0b5 100644 --- a/apps/workbench/app/controllers/groups_controller.rb +++ b/apps/workbench/app/controllers/groups_controller.rb @@ -6,8 +6,8 @@ class GroupsController < ApplicationController def index @groups = Group.filter [['group_class', '!=', 'project']] @group_uuids = @groups.collect &:uuid - @links_from = Link.where link_class: 'permission', tail_uuid: @group_uuids - @links_to = Link.where link_class: 'permission', head_uuid: @group_uuids + @links_from = Link.where(link_class: 'permission', tail_uuid: @group_uuids).with_count("none") + @links_to = Link.where(link_class: 'permission', head_uuid: @group_uuids).with_count("none") render_index end diff --git a/apps/workbench/app/controllers/jobs_controller.rb b/apps/workbench/app/controllers/jobs_controller.rb index e38d3ba87b..fd5e208d6c 100644 --- a/apps/workbench/app/controllers/jobs_controller.rb +++ b/apps/workbench/app/controllers/jobs_controller.rb @@ -24,11 +24,11 @@ class JobsController < ApplicationController nodes[j[:script_version]] = {:uuid => j[:script_version]} end - Collection.where(uuid: collections).each do |c| + Collection.where(uuid: collections).with_count("none").each do |c| nodes[c[:portable_data_hash]] = c end - Collection.where(portable_data_hash: hashes).each do |c| + Collection.where(portable_data_hash: hashes).with_count("none").each do |c| nodes[c[:portable_data_hash]] = c end diff --git a/apps/workbench/app/controllers/pipeline_instances_controller.rb b/apps/workbench/app/controllers/pipeline_instances_controller.rb index 26a9f85d4e..27719fde13 100644 --- a/apps/workbench/app/controllers/pipeline_instances_controller.rb +++ b/apps/workbench/app/controllers/pipeline_instances_controller.rb @@ -134,7 +134,7 @@ class PipelineInstancesController < ApplicationController jobs = jobs.compact.uniq if jobs.any? - Job.where(uuid: jobs).each do |j| + Job.where(uuid: jobs).with_count("none").each do |j| job_uuid = j.uuid provenance[job_uuid] = j @@ -158,7 +158,7 @@ class PipelineInstancesController < ApplicationController hashes = hashes.compact.uniq if hashes.any? - Collection.where(portable_data_hash: hashes).each do |c| + Collection.where(portable_data_hash: hashes).with_count("none").each do |c| hash_uuid = c.portable_data_hash provenance[hash_uuid] = c pips[hash_uuid] = 0 unless pips[hash_uuid] != nil @@ -168,7 +168,7 @@ class PipelineInstancesController < ApplicationController collections = collections.compact.uniq if collections.any? - Collection.where(uuid: collections).each do |c| + Collection.where(uuid: collections).with_count("none").each do |c| collection_uuid = c.uuid provenance[collection_uuid] = c pips[collection_uuid] = 0 unless pips[collection_uuid] != nil diff --git a/apps/workbench/app/controllers/projects_controller.rb b/apps/workbench/app/controllers/projects_controller.rb index cc657cbad9..6108ac687c 100644 --- a/apps/workbench/app/controllers/projects_controller.rb +++ b/apps/workbench/app/controllers/projects_controller.rb @@ -164,7 +164,7 @@ class ProjectsController < ApplicationController def destroy while (objects = Link.filter([['owner_uuid','=',@object.uuid], - ['tail_uuid','=',@object.uuid]])).any? + ['tail_uuid','=',@object.uuid]]).with_count("none")).any? objects.each do |object| object.destroy end diff --git a/apps/workbench/app/controllers/repositories_controller.rb b/apps/workbench/app/controllers/repositories_controller.rb index 6ef541ebab..953ee1dd21 100644 --- a/apps/workbench/app/controllers/repositories_controller.rb +++ b/apps/workbench/app/controllers/repositories_controller.rb @@ -50,7 +50,7 @@ class RepositoriesController < ApplicationController if !owner_filter.andand.any? filters = @filters + [["owner_uuid", "=", current_user.uuid]] - my_repos = Repository.all.order("name ASC").limit(limit).offset(offset).filter(filters).results + my_repos = Repository.all.order("name ASC").limit(limit).with_count("none").offset(offset).filter(filters).results else # done fetching all owned repositories my_repos = [] end @@ -64,7 +64,7 @@ class RepositoriesController < ApplicationController end filters = @filters + [["owner_uuid", "!=", current_user.uuid]] - other_repos = Repository.all.order("name ASC").limit(limit).offset(offset).filter(filters).results + other_repos = Repository.all.order("name ASC").limit(limit).with_count("none").offset(offset).filter(filters).results @objects = (my_repos + other_repos).first(limit) end diff --git a/apps/workbench/app/controllers/trash_items_controller.rb b/apps/workbench/app/controllers/trash_items_controller.rb index 7d6e1431ce..12ef20aa66 100644 --- a/apps/workbench/app/controllers/trash_items_controller.rb +++ b/apps/workbench/app/controllers/trash_items_controller.rb @@ -78,10 +78,10 @@ class TrashItemsController < ApplicationController base_search = base_search.filter([["modified_at", "<=", last_mod_at], ["uuid", "not in", last_uuids]]) end - base_search = base_search.include_trash(true).limit(limit).offset(offset) + base_search = base_search.include_trash(true).limit(limit).with_count("none").offset(offset) if params[:filters].andand.length.andand > 0 - tags = Link.filter(params[:filters]) + tags = Link.filter(params[:filters]).with_count("none") tagged = [] if tags.results.length > 0 tagged = query_on.include_trash(true).where(uuid: tags.collect(&:head_uuid)) @@ -95,14 +95,14 @@ class TrashItemsController < ApplicationController owner_uuids = @objects.collect(&:owner_uuid).uniq @owners = {} @not_trashed = {} - Group.filter([["uuid", "in", owner_uuids]]).include_trash(true).each do |grp| + Group.filter([["uuid", "in", owner_uuids]]).with_count("none").include_trash(true).each do |grp| @owners[grp.uuid] = grp end - User.filter([["uuid", "in", owner_uuids]]).include_trash(true).each do |grp| + User.filter([["uuid", "in", owner_uuids]]).with_count("none").include_trash(true).each do |grp| @owners[grp.uuid] = grp @not_trashed[grp.uuid] = true end - Group.filter([["uuid", "in", owner_uuids]]).select([:uuid]).each do |grp| + Group.filter([["uuid", "in", owner_uuids]]).with_count("none").select([:uuid]).each do |grp| @not_trashed[grp.uuid] = true end else diff --git a/apps/workbench/app/controllers/users_controller.rb b/apps/workbench/app/controllers/users_controller.rb index 0e86575b2e..ed5ae282dc 100644 --- a/apps/workbench/app/controllers/users_controller.rb +++ b/apps/workbench/app/controllers/users_controller.rb @@ -43,7 +43,7 @@ class UsersController < ApplicationController def activity @breadcrumb_page_name = nil - @users = User.limit(params[:limit]) + @users = User.limit(params[:limit]).with_count("none") @user_activity = {} @activity = { logins: {}, @@ -64,13 +64,13 @@ class UsersController < ApplicationController filter([[:event_type, '=', 'login'], [:object_kind, '=', 'arvados#user'], [:created_at, '>=', threshold_start], - [:created_at, '<', threshold_end]]) + [:created_at, '<', threshold_end]]).with_count("none") @activity[:jobs][span] = Job.select(%w(uuid modified_by_user_uuid)). filter([[:created_at, '>=', threshold_start], - [:created_at, '<', threshold_end]]) + [:created_at, '<', threshold_end]]).with_count("none") @activity[:pipeline_instances][span] = PipelineInstance.select(%w(uuid modified_by_user_uuid)). filter([[:created_at, '>=', threshold_start], - [:created_at, '<', threshold_end]]) + [:created_at, '<', threshold_end]]).with_count("none") @activity.each do |type, act| records = act[span] @users.each do |u| @@ -96,7 +96,7 @@ class UsersController < ApplicationController def storage @breadcrumb_page_name = nil - @users = User.limit(params[:limit]) + @users = User.limit(params[:limit]).with_count("none") @user_storage = {} total_storage = {} @log_date = {} @@ -170,7 +170,7 @@ class UsersController < ApplicationController end Link.filter([['head_uuid', 'in', collection_uuids], - ['link_class', 'in', ['tag', 'resources']]]). + ['link_class', 'in', ['tag', 'resources']]]).with_count("none") each do |link| case link.link_class when 'tag' @@ -267,14 +267,14 @@ class UsersController < ApplicationController @my_vm_logins = {} Link.where(tail_uuid: @object.uuid, link_class: 'permission', - name: 'can_login'). + name: 'can_login').with_count("none"). each do |perm_link| if perm_link.properties.andand[:username] @my_vm_logins[perm_link.head_uuid] ||= [] @my_vm_logins[perm_link.head_uuid] << perm_link.properties[:username] end end - @my_virtual_machines = VirtualMachine.where(uuid: @my_vm_logins.keys) + @my_virtual_machines = VirtualMachine.where(uuid: @my_vm_logins.keys).with_count("none") end def ssh_keys @@ -338,7 +338,7 @@ class UsersController < ApplicationController oid_login_perms = Link.where(tail_uuid: user.email, head_kind: 'arvados#user', link_class: 'permission', - name: 'can_login') + name: 'can_login').with_count("none") if oid_login_perms.any? prefix_properties = oid_login_perms.first.properties @@ -349,10 +349,10 @@ class UsersController < ApplicationController repo_perms = Link.where(tail_uuid: user.uuid, head_kind: 'arvados#repository', link_class: 'permission', - name: 'can_write') + name: 'can_write').with_count("none") if repo_perms.any? repo_uuid = repo_perms.first.head_uuid - repos = Repository.where(head_uuid: repo_uuid) + repos = Repository.where(head_uuid: repo_uuid).with_count("none") if repos.any? repo_name = repos.first.name current_selections[:repo_name] = repo_name @@ -363,7 +363,7 @@ class UsersController < ApplicationController vm_login_perms = Link.where(tail_uuid: user.uuid, head_kind: 'arvados#virtualMachine', link_class: 'permission', - name: 'can_login') + name: 'can_login').with_count("none") if vm_login_perms.any? vm_perm = vm_login_perms.first vm_uuid = vm_perm.head_uuid diff --git a/apps/workbench/app/controllers/virtual_machines_controller.rb b/apps/workbench/app/controllers/virtual_machines_controller.rb index 19763b926c..785a703038 100644 --- a/apps/workbench/app/controllers/virtual_machines_controller.rb +++ b/apps/workbench/app/controllers/virtual_machines_controller.rb @@ -10,7 +10,7 @@ class VirtualMachinesController < ApplicationController Link.where(tail_uuid: current_user.uuid, head_uuid: @objects.collect(&:uuid), link_class: 'permission', - name: 'can_login'). + name: 'can_login').with_count("none"). each do |perm_link| if perm_link.properties.andand[:username] @vm_logins[perm_link.head_uuid] ||= [] diff --git a/apps/workbench/app/controllers/work_unit_templates_controller.rb b/apps/workbench/app/controllers/work_unit_templates_controller.rb index 1dba520a7a..0376590a55 100644 --- a/apps/workbench/app/controllers/work_unit_templates_controller.rb +++ b/apps/workbench/app/controllers/work_unit_templates_controller.rb @@ -12,12 +12,12 @@ class WorkUnitTemplatesController < ApplicationController # get next page of pipeline_templates if PipelineTemplate.api_exists?(:index) filters = @filters + [["uuid", "is_a", ["arvados#pipelineTemplate"]]] - pipelines = PipelineTemplate.limit(@limit).order(["created_at desc"]).filter(filters) + pipelines = PipelineTemplate.limit(@limit).with_count("none").order(["created_at desc"]).filter(filters) end # get next page of workflows filters = @filters + [["uuid", "is_a", ["arvados#workflow"]]] - workflows = Workflow.limit(@limit).order(["created_at desc"]).filter(filters) + workflows = Workflow.limit(@limit).order(["created_at desc"]).with_count("none").filter(filters) @objects = (pipelines.to_a + workflows.to_a).sort_by(&:created_at).reverse.first(@limit) diff --git a/apps/workbench/app/controllers/work_units_controller.rb b/apps/workbench/app/controllers/work_units_controller.rb index 0f0033ce49..dc0def71bf 100644 --- a/apps/workbench/app/controllers/work_units_controller.rb +++ b/apps/workbench/app/controllers/work_units_controller.rb @@ -23,14 +23,14 @@ class WorkUnitsController < ApplicationController # get next page of pipeline_instances if PipelineInstance.api_exists?(:index) filters = @filters + [["uuid", "is_a", ["arvados#pipelineInstance"]]] - pipelines = PipelineInstance.limit(@limit).order(["created_at desc"]).filter(filters) + pipelines = PipelineInstance.limit(@limit).order(["created_at desc"]).filter(filters).with_count("none") end if params[:show_children] # get next page of jobs if Job.api_exists?(:index) filters = @filters + [["uuid", "is_a", ["arvados#job"]]] - jobs = Job.limit(@limit).order(["created_at desc"]).filter(filters) + jobs = Job.limit(@limit).order(["created_at desc"]).filter(filters).with_count("none") end end @@ -39,7 +39,7 @@ class WorkUnitsController < ApplicationController if !params[:show_children] filters << ["requesting_container_uuid", "=", nil] end - crs = ContainerRequest.limit(@limit).order(["created_at desc"]).filter(filters) + crs = ContainerRequest.limit(@limit).order(["created_at desc"]).filter(filters).with_count("none") @objects = (jobs.to_a + pipelines.to_a + crs.to_a).sort_by(&:created_at).reverse.first(@limit) if @objects.any? diff --git a/apps/workbench/app/helpers/pipeline_instances_helper.rb b/apps/workbench/app/helpers/pipeline_instances_helper.rb index 2142375226..cbff77b937 100644 --- a/apps/workbench/app/helpers/pipeline_instances_helper.rb +++ b/apps/workbench/app/helpers/pipeline_instances_helper.rb @@ -92,7 +92,7 @@ module PipelineInstancesHelper c[:job][:uuid] if c.is_a?(Hash) and c[:job].is_a?(Hash) }.compact job = {} - Job.where(uuid: jobuuids).each do |j| + Job.where(uuid: jobuuids).with_count("none").each do |j| job[j[:uuid]] = j end diff --git a/apps/workbench/app/models/container_work_unit.rb b/apps/workbench/app/models/container_work_unit.rb index ef20a7f8f4..3f26e72d16 100644 --- a/apps/workbench/app/models/container_work_unit.rb +++ b/apps/workbench/app/models/container_work_unit.rb @@ -24,11 +24,11 @@ class ContainerWorkUnit < ProxyWorkUnit container_uuid = if @proxied.is_a?(Container) then uuid else get(:container_uuid) end if container_uuid cols = ContainerRequest.columns.map(&:name) - %w(id updated_at mounts secret_mounts runtime_token) - my_children = @child_proxies || ContainerRequest.select(cols).where(requesting_container_uuid: container_uuid).results if !my_children + my_children = @child_proxies || ContainerRequest.select(cols).where(requesting_container_uuid: container_uuid).with_count("none").results if !my_children my_child_containers = my_children.map(&:container_uuid).compact.uniq grandchildren = {} my_child_containers.each { |c| grandchildren[c] = []} if my_child_containers.any? - reqs = ContainerRequest.select(cols).where(requesting_container_uuid: my_child_containers).results if my_child_containers.any? + reqs = ContainerRequest.select(cols).where(requesting_container_uuid: my_child_containers).with_count("none").results if my_child_containers.any? reqs.each {|cr| grandchildren[cr.requesting_container_uuid] << cr} if reqs my_children.each do |cr| diff --git a/apps/workbench/app/models/pipeline_instance.rb b/apps/workbench/app/models/pipeline_instance.rb index dd2cc0ab77..d481f41c7e 100644 --- a/apps/workbench/app/models/pipeline_instance.rb +++ b/apps/workbench/app/models/pipeline_instance.rb @@ -127,10 +127,10 @@ class PipelineInstance < ArvadosBase Keep::Locator.parse(loc_s) end if log_pdhs.any? and - Collection.where(portable_data_hash: log_pdhs).limit(1).results.any? + Collection.where(portable_data_hash: log_pdhs).limit(1).with_count("none").results.any? true elsif log_uuids.any? and - Collection.where(uuid: log_uuids).limit(1).results.any? + Collection.where(uuid: log_uuids).limit(1).with_count("none").results.any? true else stderr_log_query(1).results.any? diff --git a/apps/workbench/app/models/pipeline_instance_work_unit.rb b/apps/workbench/app/models/pipeline_instance_work_unit.rb index a9bc9cfb59..1d75f58433 100644 --- a/apps/workbench/app/models/pipeline_instance_work_unit.rb +++ b/apps/workbench/app/models/pipeline_instance_work_unit.rb @@ -9,7 +9,7 @@ class PipelineInstanceWorkUnit < ProxyWorkUnit items = [] jobs = {} - results = Job.where(uuid: @proxied.job_ids.values).results + results = Job.where(uuid: @proxied.job_ids.values).with_count("none").results results.each do |j| jobs[j.uuid] = j end