Files
ubicloud/model/project.rb
Jeremy Evans a76c6259d8 Fix 9N+1 query issue when closing an account
For each of the account's projects, this ran 9 separate queries:
1 for the accounts, and 1 for each of the 8 resource associations.

Change this to 8-9 queries total.  Add a first_project_with_resources
dataset method to Project.  This methods issues one query per
resource association to find any objects related to the project in
the dataset, using Sequel's filtering by associations support.
If it finds a related object, it returns the project related to the
object.

To handle the filtering for projects with only a single account,
use a subquery that checks that the access_tag table only has one
entry for the project.
2025-06-25 06:52:58 +09:00

9.1 KiB