diff options
author | Stan Hu <stanhu@gmail.com> | 2017-03-31 09:00:00 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2017-03-31 09:00:00 +0300 |
commit | ced1bbab0cd981a23d653672a01e05c8c077fdc1 (patch) | |
tree | ac3a479b5556c0978b83b02f1e99da07feaf2e48 /app | |
parent | bcb0a554dd4f8754ab1d6a876edc1481e04aa711 (diff) |
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]]
```
Diffstat (limited to 'app')
-rw-r--r-- | app/models/project_team.rb | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/app/models/project_team.rb b/app/models/project_team.rb index 8a53e974b6f..6d6644053f8 100644 --- a/app/models/project_team.rb +++ b/app/models/project_team.rb @@ -169,6 +169,9 @@ class ProjectTeam # Lookup only the IDs we need user_ids = user_ids - access.keys + + return access if user_ids.empty? + users_access = project.project_authorizations. where(user: user_ids). group(:user_id). |