Commit ced1bbab authored by Stan Hu's avatar Stan Hu

Eliminate unnecessary queries that add ~500 ms of load time for a large issue

Looking at the SQL log, we see useless queries such as:

```
D, [2017-03-22T03:25:00.726710 #2629] DEBUG -- :    (235.9ms)  SELECT MAX("project_authorizations"."access_level") AS maximum_access_level, "project_authorizations"."user_id" AS project_authorizations_user_id FROM "project_authorizations" WHERE "project_authorizations"."project_id" = 13083 AND 1=0 GROUP BY "project_authorizations"."user_id"  [["project_id", 13083]]
```
parent bcb0a554
...@@ -169,6 +169,9 @@ class ProjectTeam ...@@ -169,6 +169,9 @@ class ProjectTeam
# Lookup only the IDs we need # Lookup only the IDs we need
user_ids = user_ids - access.keys user_ids = user_ids - access.keys
return access if user_ids.empty?
users_access = project.project_authorizations. users_access = project.project_authorizations.
where(user: user_ids). where(user: user_ids).
group(:user_id). group(:user_id).
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment