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
02b9fa03
Commit
02b9fa03
authored
Feb 20, 2018
by
Andreas Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename use_conditions_only option to use_where_in.
parent
715183da
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
4 deletions
+4
-4
app/finders/snippets_finder.rb
app/finders/snippets_finder.rb
+1
-1
app/models/project.rb
app/models/project.rb
+3
-3
No files found.
app/finders/snippets_finder.rb
View file @
02b9fa03
...
@@ -56,7 +56,7 @@ class SnippetsFinder < UnionFinder
...
@@ -56,7 +56,7 @@ class SnippetsFinder < UnionFinder
end
end
def
feature_available_projects
def
feature_available_projects
projects
=
Project
.
public_or_visible_to_user
(
current_user
,
use_
conditions_only
:
false
)
do
|
part
|
projects
=
Project
.
public_or_visible_to_user
(
current_user
,
use_
where_in
:
false
)
do
|
part
|
part
.
with_feature_available_for_user
(
:snippets
,
current_user
)
part
.
with_feature_available_for_user
(
:snippets
,
current_user
)
end
.
select
(
:id
)
end
.
select
(
:id
)
...
...
app/models/project.rb
View file @
02b9fa03
...
@@ -322,10 +322,10 @@ class Project < ActiveRecord::Base
...
@@ -322,10 +322,10 @@ class Project < ActiveRecord::Base
# This is useful for performance as we can stick those additional filters
# This is useful for performance as we can stick those additional filters
# at the bottom of e.g. the UNION.
# at the bottom of e.g. the UNION.
#
#
# Optionally, turning `use_
conditions_only
` off leads to returning a
# Optionally, turning `use_
where_in
` off leads to returning a
# relation using #from instead of #where. This can perform much better
# relation using #from instead of #where. This can perform much better
# but leads to trouble when used in conjunction with AR's #merge method.
# but leads to trouble when used in conjunction with AR's #merge method.
def
self
.
public_or_visible_to_user
(
user
=
nil
,
use_
conditions_only
:
true
,
&
block
)
def
self
.
public_or_visible_to_user
(
user
=
nil
,
use_
where_in
:
true
,
&
block
)
# If we don't get a block passed, use identity to avoid if/else repetitions
# If we don't get a block passed, use identity to avoid if/else repetitions
block
=
->
(
part
)
{
part
}
unless
block_given?
block
=
->
(
part
)
{
part
}
unless
block_given?
...
@@ -348,7 +348,7 @@ class Project < ActiveRecord::Base
...
@@ -348,7 +348,7 @@ class Project < ActiveRecord::Base
# performance.
# performance.
union
=
Gitlab
::
SQL
::
Union
.
new
([
authorized_projects
.
select
(
'projects.id'
),
visible_projects
.
select
(
'projects.id'
)])
union
=
Gitlab
::
SQL
::
Union
.
new
([
authorized_projects
.
select
(
'projects.id'
),
visible_projects
.
select
(
'projects.id'
)])
if
use_
conditions_only
if
use_
where_in
where
(
"projects.id IN (
#{
union
.
to_sql
}
)"
)
# rubocop:disable GitlabSecurity/SqlInjection
where
(
"projects.id IN (
#{
union
.
to_sql
}
)"
)
# rubocop:disable GitlabSecurity/SqlInjection
else
else
from
(
"(
#{
union
.
to_sql
}
) AS
#{
table_name
}
"
)
from
(
"(
#{
union
.
to_sql
}
) AS
#{
table_name
}
"
)
...
...
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