Skip to content

Commit

Permalink
refactor running_and_pending_tasks_count from nested selects to joins
Browse files Browse the repository at this point in the history
  • Loading branch information
kathap committed Dec 5, 2023
1 parent 4031e9d commit 5cfbc52
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/models/runtime/organization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,11 @@ def members
end

def running_and_pending_tasks_count
tasks_dataset.where(state: [TaskModel::PENDING_STATE, TaskModel::RUNNING_STATE]).count
VCAP::CloudController::TaskModel.dataset.where(state: [TaskModel::PENDING_STATE, TaskModel::RUNNING_STATE]).
join(:apps, guid: :app_guid).
join(:spaces, guid: :space_guid).
where(spaces__organization_id: id).
count
end

private
Expand Down

0 comments on commit 5cfbc52

Please sign in to comment.