summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-06-04 10:49:08 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-06-04 10:49:08 +0000
commitec8d39897c76439c71b79738c5a348b36a03753b (patch)
tree6deba310d86457fa0fec92242a960c49de68a487 /app
parent671756e9ff3695ee28513e51f636779e1aa49089 (diff)
parenta89c590ffef54c9ff4c790b5d91a8afe68b1ee42 (diff)
downloadgitlab-ce-ec8d39897c76439c71b79738c5a348b36a03753b.tar.gz
Merge branch 'perforemance-improve' into 'master'
Performance improve Fixes #1315. For group with 500 users it reduce amount of sql queries from 500 to 20. It reduces page load ~ 3 times or even more. For larger group it will be even more difference
Diffstat (limited to 'app')
-rw-r--r--app/models/ability.rb8
-rw-r--r--app/models/project_team.rb16
2 files changed, 20 insertions, 4 deletions
diff --git a/app/models/ability.rb b/app/models/ability.rb
index 70c26caded8..df9b210dfca 100644
--- a/app/models/ability.rb
+++ b/app/models/ability.rb
@@ -71,16 +71,16 @@ class Ability
team = project.team
# Rules based on role in project
- if team.masters.include?(user)
+ if team.master?(user)
rules += project_master_rules
- elsif team.developers.include?(user)
+ elsif team.developer?(user)
rules += project_dev_rules
- elsif team.reporters.include?(user)
+ elsif team.reporter?(user)
rules += project_report_rules
- elsif team.guests.include?(user)
+ elsif team.guest?(user)
rules += project_guest_rules
end
diff --git a/app/models/project_team.rb b/app/models/project_team.rb
index eca13e56061..cc8bb60aac4 100644
--- a/app/models/project_team.rb
+++ b/app/models/project_team.rb
@@ -117,6 +117,22 @@ class ProjectTeam
false
end
+ def guest?(user)
+ find_tm(user.id).try(:access_field) == Gitlab::Access::GUEST
+ end
+
+ def reporter?(user)
+ find_tm(user.id).try(:access_field) == Gitlab::Access::REPORTER
+ end
+
+ def developer?(user)
+ find_tm(user.id).try(:access_field) == Gitlab::Access::DEVELOPER
+ end
+
+ def master?(user)
+ find_tm(user.id).try(:access_field) == Gitlab::Access::MASTER
+ end
+
private
def fetch_members(level = nil)