Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
bb5af954
Commit
bb5af954
authored
Nov 29, 2019
by
Adam Hegyi
Committed by
Mayra Cabrera
Nov 29, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve .groups_user_can_read_epics performance
parent
69c31c11
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
2 deletions
+26
-2
ee/app/models/ee/epic.rb
ee/app/models/ee/epic.rb
+7
-1
ee/spec/models/epic_spec.rb
ee/spec/models/epic_spec.rb
+19
-1
No files found.
ee/app/models/ee/epic.rb
View file @
bb5af954
...
...
@@ -196,7 +196,13 @@ module EE
end
def
groups_user_can_read_epics
(
epics
,
user
)
groups
=
::
Group
.
where
(
id:
epics
.
select
(
:group_id
))
groups
=
if
::
Feature
.
enabled?
(
:optimized_groups_user_can_read_epics_method
)
epics_query
=
epics
.
select
(
:group_id
)
::
Group
.
joins
(
"INNER JOIN (
#{
epics_query
.
to_sql
}
) as epics on epics.group_id = namespaces.id"
)
else
::
Group
.
where
(
id:
epics
.
select
(
:group_id
))
end
groups
=
::
Gitlab
::
GroupPlansPreloader
.
new
.
preload
(
groups
)
DeclarativePolicy
.
user_scope
do
...
...
ee/spec/models/epic_spec.rb
View file @
bb5af954
...
...
@@ -101,7 +101,7 @@ describe Epic do
end
end
describe
'.groups_user_can_read_epic
s'
do
shared_examples
'.groups_user_can_read_epics example
s'
do
let_it_be
(
:private_group
)
{
create
(
:group
,
:private
)
}
let_it_be
(
:epic
)
{
create
(
:epic
,
group:
private_group
)
}
...
...
@@ -141,6 +141,24 @@ describe Epic do
end
end
describe
'.groups_user_can_read_epics'
do
context
'with `optimized_groups_user_can_read_epics_method` feature flag enabled'
do
before
do
stub_feature_flags
(
optimized_groups_user_can_read_epics_method:
true
)
end
include_examples
'.groups_user_can_read_epics examples'
end
context
'with `optimized_groups_user_can_read_epics_method` feature flag disabled'
do
before
do
stub_feature_flags
(
optimized_groups_user_can_read_epics_method:
false
)
end
include_examples
'.groups_user_can_read_epics examples'
end
end
describe
'#valid_parent?'
do
context
'basic checks'
do
let
(
:epic
)
{
build
(
:epic
,
group:
group
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment