Commit ec8d3989 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

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
parents 671756e9 a89c590f
...@@ -17,6 +17,7 @@ v 7.0.0 ...@@ -17,6 +17,7 @@ v 7.0.0
- UI improvements - UI improvements
- Case-insensetive search for issues - Case-insensetive search for issues
- Update to rails 4.1 - Update to rails 4.1
- Improve performance of application for projects and groups with a lot of members
v 6.9.2 v 6.9.2
- Revert the commit that broke the LDAP user filter - Revert the commit that broke the LDAP user filter
......
...@@ -71,16 +71,16 @@ class Ability ...@@ -71,16 +71,16 @@ class Ability
team = project.team team = project.team
# Rules based on role in project # Rules based on role in project
if team.masters.include?(user) if team.master?(user)
rules += project_master_rules rules += project_master_rules
elsif team.developers.include?(user) elsif team.developer?(user)
rules += project_dev_rules rules += project_dev_rules
elsif team.reporters.include?(user) elsif team.reporter?(user)
rules += project_report_rules rules += project_report_rules
elsif team.guests.include?(user) elsif team.guest?(user)
rules += project_guest_rules rules += project_guest_rules
end end
......
...@@ -117,6 +117,22 @@ class ProjectTeam ...@@ -117,6 +117,22 @@ class ProjectTeam
false false
end 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 private
def fetch_members(level = nil) def fetch_members(level = nil)
......
require "spec_helper" require "spec_helper"
describe ProjectTeam do describe ProjectTeam do
let(:team) { create(:project).team } let(:group) { create(:group) }
let(:project) { create(:empty_project, group: group) }
describe "Respond to" do let(:master) { create(:user) }
subject { team } let(:reporter) { create(:user) }
let(:guest) { create(:user) }
let(:nonmember) { create(:user) }
it { should respond_to(:developers) } before do
it { should respond_to(:masters) } group.add_user(master, Gitlab::Access::MASTER)
it { should respond_to(:reporters) } group.add_user(reporter, Gitlab::Access::REPORTER)
it { should respond_to(:guests) } group.add_user(guest, Gitlab::Access::GUEST)
# Add group guest as master to this project
# to test project access priority over group members
project.team << [guest, :master]
end
describe 'members collection' do
it { team.masters.should include(master) }
it { team.masters.should include(guest) }
it { team.masters.should_not include(reporter) }
it { team.masters.should_not include(nonmember) }
end
describe 'access methods' do
it { team.master?(master).should be_true }
it { team.master?(guest).should be_true }
it { team.master?(reporter).should be_false }
it { team.master?(nonmember).should be_false }
end end
end end
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