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
15ef3f62
Commit
15ef3f62
authored
Dec 14, 2020
by
Alex Ives
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rerverts query changes that did not return relation
Relates to
https://gitlab.com/gitlab-org/gitlab/issues/293713
parent
e5ae08ac
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
21 deletions
+18
-21
ee/app/models/ee/snippet_repository.rb
ee/app/models/ee/snippet_repository.rb
+18
-21
No files found.
ee/app/models/ee/snippet_repository.rb
View file @
15ef3f62
...
...
@@ -17,33 +17,30 @@ module EE
def
replicables_for_current_secondary
(
primary_key_in
)
node
=
::
Gitlab
::
Geo
.
current_node
if
!
node
.
selective_sync?
all
.
primary_key_in
(
primary_key_in
)
elsif
node
.
selective_sync_by_namespaces?
snippet_repositories_for_selected_namespaces
(
primary_key_in
)
elsif
node
.
selective_sync_by_shards?
snippet_repositories_for_selected_shards
(
primary_key_in
)
else
self
.
none
end
replicables
=
if
!
node
.
selective_sync?
all
elsif
node
.
selective_sync_by_namespaces?
snippet_repositories_for_selected_namespaces
elsif
node
.
selective_sync_by_shards?
snippet_repositories_for_selected_shards
else
self
.
none
end
replicables
.
primary_key_in
(
primary_key_in
)
end
def
snippet_repositories_for_selected_namespaces
(
primary_key_in
)
personal_snippets
=
self
.
where
(
snippet:
::
Snippet
.
only_personal_snippets
.
primary_key_in
(
primary_key_in
)
)
def
snippet_repositories_for_selected_namespaces
personal_snippets
=
self
.
joins
(
:snippet
).
where
(
snippet:
::
Snippet
.
only_personal_snippets
)
project_snippets
=
self
.
where
(
snippet:
::
Snippet
.
for_projects
(
::
Gitlab
::
Geo
.
current_node
.
projects
.
select
(
:id
)
)
.
primary_key_in
(
primary_key_in
))
project_snippets
=
self
.
joins
(
snippet: :project
)
.
merge
(
::
Snippet
.
for_projects
(
::
Gitlab
::
Geo
.
current_node
.
projects
.
select
(
:id
)
))
# We use `find_by_sql` here in order to perform the union operation and cast the results as
# Snippet repositories. If we use a `from_union`, it wraps the query in in a sub-select and
# it increases the query time by a surprising amount.
self
.
find_by_sql
(
::
Gitlab
::
SQL
::
Union
.
new
([
project_snippets
,
personal_snippets
]).
to_sql
)
self
.
from_union
([
project_snippets
,
personal_snippets
])
end
def
snippet_repositories_for_selected_shards
(
primary_key_in
)
self
.
for_repository_storage
(
::
Gitlab
::
Geo
.
current_node
.
selective_sync_shards
)
.
primary_key_in
(
primary_key_in
)
def
snippet_repositories_for_selected_shards
self
.
for_repository_storage
(
::
Gitlab
::
Geo
.
current_node
.
selective_sync_shards
)
end
end
...
...
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