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
d800b5fa
Commit
d800b5fa
authored
Dec 04, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring Lfs Object finder to count registries instead of using FDW
parent
c01e9041
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
44 deletions
+19
-44
app/models/geo_node_status.rb
app/models/geo_node_status.rb
+2
-2
ee/app/finders/geo/lfs_object_registry_finder.rb
ee/app/finders/geo/lfs_object_registry_finder.rb
+17
-42
No files found.
app/models/geo_node_status.rb
View file @
d800b5fa
...
...
@@ -76,8 +76,8 @@ class GeoNodeStatus < ActiveRecord::Base
self
.
repositories_failed_count
=
geo_node
.
project_registries
.
failed
.
count
lfs_objects_finder
=
Geo
::
LfsObjectRegistryFinder
.
new
(
current_node:
geo_node
)
self
.
lfs_objects_synced_count
=
lfs_objects_finder
.
find_synced_lfs_objects
.
count
self
.
lfs_objects_failed_count
=
lfs_objects_finder
.
find_failed_lfs_objects
.
count
self
.
lfs_objects_synced_count
=
lfs_objects_finder
.
count_synced_lfs_objects
self
.
lfs_objects_failed_count
=
lfs_objects_finder
.
count_failed_lfs_objects
attachments_finder
=
Geo
::
AttachmentRegistryFinder
.
new
(
current_node:
geo_node
)
self
.
attachments_synced_count
=
attachments_finder
.
find_synced_attachments
.
count
...
...
ee/app/finders/geo/lfs_object_registry_finder.rb
View file @
d800b5fa
module
Geo
class
LfsObjectRegistryFinder
<
RegistryFinder
def
find
_synced_lfs_objects
def
count
_synced_lfs_objects
relation
=
if
fdw?
fdw_find_synced_lfs_objects
else
if
selective_sync?
legacy_find_synced_lfs_objects
end
relation
end
def
find_failed_lfs_objects
relation
=
if
fdw?
fdw_find_failed_lfs_objects
else
legacy_find_failed_lfs_object
s
find_synced_lfs_objects_registrie
s
end
relation
relation
.
count
end
private
def
lfs_objects
lfs_object_model
=
fdw?
?
Geo
::
Fdw
::
LfsObject
:
LfsObject
def
count_failed_lfs_objects
relation
=
if
selective_sync?
l
fs_object_model
.
joins
(
:projects
).
where
(
projects:
{
id:
current_node
.
projects
})
l
egacy_find_failed_lfs_objects
else
lfs_object_model
.
all
find_failed_lfs_objects_registries
end
relation
.
with_files_stored_locally
relation
.
count
end
#
# FDW accessors
#
def
fdw_table
Geo
::
Fdw
::
LfsObject
.
table_name
end
private
def
fdw_find_synced_lfs_objects
lfs_objects
.
joins
(
"INNER JOIN file_registry ON file_registry.file_id =
#{
fdw_table
}
.id"
)
.
merge
(
Geo
::
FileRegistry
.
lfs_objects
)
.
merge
(
Geo
::
FileRegistry
.
synced
)
def
find_synced_lfs_objects_registries
Geo
::
FileRegistry
.
lfs_objects
.
synced
end
def
fdw_find_failed_lfs_objects
lfs_objects
.
joins
(
"INNER JOIN file_registry ON file_registry.file_id =
#{
fdw_table
}
.id"
)
.
merge
(
Geo
::
FileRegistry
.
lfs_objects
)
.
merge
(
Geo
::
FileRegistry
.
failed
)
def
find_failed_lfs_objects_registries
Geo
::
FileRegistry
.
lfs_objects
.
failed
end
#
# Legacy accessors (non FDW)
#
def
legacy_find_synced_lfs_objects
legacy_find_lfs_objects
(
Geo
::
FileRegistry
.
lfs_objects
.
synced
.
pluck
(
:file_id
))
end
...
...
@@ -72,6 +43,10 @@ module Geo
def
legacy_find_lfs_objects
(
registry_file_ids
)
return
LfsObject
.
none
if
registry_file_ids
.
empty?
lfs_objects
=
LfsObject
.
joins
(
:projects
)
.
where
(
projects:
{
id:
current_node
.
projects
})
.
with_files_stored_locally
joined_relation
=
lfs_objects
.
joins
(
<<~
SQL
)
INNER JOIN
(VALUES
#{
registry_file_ids
.
map
{
|
id
|
"(
#{
id
}
)"
}
.join(',')})
...
...
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