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
27374be1
Commit
27374be1
authored
Dec 06, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid use of pluck(:id) to fetch uploads for nodes with selective sync
parent
6811caab
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
14 deletions
+32
-14
app/models/geo_node.rb
app/models/geo_node.rb
+5
-2
ee/app/finders/geo/attachment_registry_finder.rb
ee/app/finders/geo/attachment_registry_finder.rb
+27
-12
No files found.
app/models/geo_node.rb
View file @
27374be1
...
...
@@ -151,9 +151,12 @@ class GeoNode < ActiveRecord::Base
def
uploads
if
selective_sync?
namespace_ids
=
Gitlab
::
GroupHierarchy
.
new
(
Gitlab
::
Geo
.
current_node
.
namespaces
).
base_and_descendants
.
select
(
:id
)
project_ids
=
Gitlab
::
Geo
.
current_node
.
projects
.
select
(
:id
)
uploads_table
=
Upload
.
arel_table
group_uploads
=
uploads_table
[
:model_type
].
eq
(
'Namespace'
).
and
(
uploads_table
[
:model_id
].
in
(
Gitlab
::
GroupHierarchy
.
new
(
namespaces
).
base_and_descendants
.
pluck
(
:id
)))
project_uploads
=
uploads_table
[
:model_type
].
eq
(
'Project'
).
and
(
uploads_table
[
:model_id
].
in
(
projects
.
pluck
(
:id
)))
group_uploads
=
uploads_table
[
:model_type
].
eq
(
'Namespace'
).
and
(
uploads_table
[
:model_id
].
in
(
Arel
::
Nodes
::
SqlLiteral
.
new
(
namespace_ids
.
to_sql
)))
project_uploads
=
uploads_table
[
:model_type
].
eq
(
'Project'
).
and
(
uploads_table
[
:model_id
].
in
(
Arel
::
Nodes
::
SqlLiteral
.
new
(
project_ids
.
to_sql
)))
other_uploads
=
uploads_table
[
:model_type
].
not_in
(
%w[Namespace Project]
)
Upload
.
where
(
group_uploads
.
or
(
project_uploads
).
or
(
other_uploads
))
...
...
ee/app/finders/geo/attachment_registry_finder.rb
View file @
27374be1
...
...
@@ -2,7 +2,7 @@ module Geo
class
AttachmentRegistryFinder
<
RegistryFinder
def
find_synced_attachments
relation
=
if
Gitlab
::
Geo
.
fdw?
if
fdw?
fdw_find_synced_attachments
else
legacy_find_synced_attachments
...
...
@@ -13,7 +13,7 @@ module Geo
def
find_failed_attachments
relation
=
if
Gitlab
::
Geo
.
fdw?
if
fdw?
fdw_find_failed_attachments
else
legacy_find_failed_attachments
...
...
@@ -25,20 +25,35 @@ module Geo
private
def
uploads
upload_model
=
Gitlab
::
Geo
.
fdw?
?
Geo
::
Fdw
::
Upload
:
Upload
if
selective_sync?
upload_table
=
upload_model
.
arel_table
group_uploads
=
upload_table
[
:model_type
].
eq
(
'Namespace'
).
and
(
upload_table
[
:model_id
].
in
(
Gitlab
::
GroupHierarchy
.
new
(
current_node
.
namespaces
).
base_and_descendants
.
pluck
(
:id
)))
project_uploads
=
upload_table
[
:model_type
].
eq
(
'Project'
).
and
(
upload_table
[
:model_id
].
in
(
current_node
.
projects
.
pluck
(
:id
)))
other_uploads
=
upload_table
[
:model_type
].
not_in
(
%w[Namespace Project]
)
upload_model
.
where
(
group_uploads
.
or
(
project_uploads
).
or
(
other_uploads
))
Upload
.
where
(
group_uploads
.
or
(
project_uploads
).
or
(
other_uploads
))
else
upload_model
.
all
Upload
.
all
end
end
def
group_uploads
namespace_ids
=
Gitlab
::
GroupHierarchy
.
new
(
current_node
.
namespaces
).
base_and_descendants
.
select
(
:id
)
arel_namespace_ids
=
Arel
::
Nodes
::
SqlLiteral
.
new
(
namespace_ids
.
to_sql
)
upload_table
[
:model_type
].
eq
(
'Namespace'
).
and
(
upload_table
[
:model_id
].
in
(
arel_namespace_ids
))
end
def
project_uploads
project_ids
=
current_node
.
projects
.
select
(
:id
)
arel_project_ids
=
Arel
::
Nodes
::
SqlLiteral
.
new
(
project_ids
.
to_sql
)
upload_table
[
:model_type
].
eq
(
'Project'
).
and
(
upload_table
[
:model_id
].
in
(
arel_project_ids
))
end
def
other_uploads
upload_table
[
:model_type
].
not_in
(
%w[Namespace Project]
)
end
def
upload_table
Upload
.
arel_table
end
#
# FDW accessors
#
...
...
@@ -54,7 +69,7 @@ module Geo
def
fdw_find_attachments
fdw_table
=
Geo
::
Fdw
::
Upload
.
table_name
uploads
.
joins
(
"INNER JOIN file_registry ON file_registry.file_id =
#{
fdw_table
}
.id"
)
Geo
::
Fdw
::
Upload
.
joins
(
"INNER JOIN file_registry ON file_registry.file_id =
#{
fdw_table
}
.id"
)
.
merge
(
Geo
::
FileRegistry
.
attachments
)
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