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
9967fc58
Commit
9967fc58
authored
Nov 06, 2019
by
Michael Kozono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor LFS methods
Shorten names that are already unambiguous.
parent
5d94e9d2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
25 deletions
+25
-25
ee/app/finders/geo/lfs_object_registry_finder.rb
ee/app/finders/geo/lfs_object_registry_finder.rb
+2
-2
ee/app/models/geo/fdw/lfs_object.rb
ee/app/models/geo/fdw/lfs_object.rb
+13
-13
ee/lib/gitlab/geo/fdw/lfs_object_registry_query_builder.rb
ee/lib/gitlab/geo/fdw/lfs_object_registry_query_builder.rb
+8
-8
ee/spec/models/geo/fdw/lfs_object_spec.rb
ee/spec/models/geo/fdw/lfs_object_spec.rb
+2
-2
No files found.
ee/app/finders/geo/lfs_object_registry_finder.rb
View file @
9967fc58
...
...
@@ -41,7 +41,7 @@ module Geo
# rubocop:disable CodeReuse/ActiveRecord
def
find_unsynced
(
batch_size
:,
except_ids:
[])
lfs_objects
.
missing_
file_
registry
.
missing_registry
.
id_not_in
(
except_ids
)
.
limit
(
batch_size
)
end
...
...
@@ -50,7 +50,7 @@ module Geo
# rubocop:disable CodeReuse/ActiveRecord
def
find_migrated_local
(
batch_size
:,
except_ids:
[])
all_lfs_objects
.
inner_join_
lfs_object_
registry
.
inner_join_registry
.
with_files_stored_remotely
.
id_not_in
(
except_ids
)
.
limit
(
batch_size
)
...
...
ee/app/models/geo/fdw/lfs_object.rb
View file @
9967fc58
...
...
@@ -17,45 +17,45 @@ module Geo
class
<<
self
def
failed
inner_join_
lfs_object_
registry
inner_join_registry
.
merge
(
Geo
::
LfsObjectRegistry
.
failed
)
end
def
inner_join_
lfs_object_
registry
def
inner_join_registry
join_statement
=
arel_table
.
join
(
lfs_object_
registry_table
,
Arel
::
Nodes
::
InnerJoin
)
.
on
(
arel_table
[
:id
].
eq
(
lfs_object_
registry_table
[
:lfs_object_id
]))
.
join
(
registry_table
,
Arel
::
Nodes
::
InnerJoin
)
.
on
(
arel_table
[
:id
].
eq
(
registry_table
[
:lfs_object_id
]))
joins
(
join_statement
.
join_sources
)
end
def
missing_
file_
registry
left_outer_join_
lfs_object_
registry
.
where
(
lfs_object_
registry_table
[
:id
].
eq
(
nil
))
def
missing_registry
left_outer_join_registry
.
where
(
registry_table
[
:id
].
eq
(
nil
))
end
def
missing_on_primary
inner_join_
lfs_object_
registry
inner_join_registry
.
merge
(
Geo
::
LfsObjectRegistry
.
synced
.
missing_on_primary
)
end
def
synced
inner_join_
lfs_object_
registry
inner_join_registry
.
merge
(
Geo
::
LfsObjectRegistry
.
synced
)
end
private
def
lfs_object_
registry_table
def
registry_table
Geo
::
LfsObjectRegistry
.
arel_table
end
def
left_outer_join_
lfs_object_
registry
def
left_outer_join_registry
join_statement
=
arel_table
.
join
(
lfs_object_
registry_table
,
Arel
::
Nodes
::
OuterJoin
)
.
on
(
arel_table
[
:id
].
eq
(
lfs_object_
registry_table
[
:lfs_object_id
]))
.
join
(
registry_table
,
Arel
::
Nodes
::
OuterJoin
)
.
on
(
arel_table
[
:id
].
eq
(
registry_table
[
:lfs_object_id
]))
joins
(
join_statement
.
join_sources
)
end
...
...
ee/lib/gitlab/geo/fdw/lfs_object_registry_query_builder.rb
View file @
9967fc58
...
...
@@ -14,10 +14,10 @@ module Gitlab
class
Fdw
class
LfsObjectRegistryQueryBuilder
<
BaseQueryBuilder
# rubocop:disable CodeReuse/ActiveRecord
def
for_lfs_objects
(
lfs_object_
ids
)
def
for_lfs_objects
(
ids
)
query
.
joins
(
fdw_inner_join_lfs_objects
)
.
lfs_object_id_in
(
lfs_object_
ids
)
.
lfs_object_id_in
(
ids
)
end
# rubocop:enable CodeReuse/ActiveRecord
...
...
@@ -25,21 +25,21 @@ module Gitlab
def
base
::
Geo
::
LfsObjectRegistry
.
select
(
lfs_
registry_table
[
Arel
.
star
])
.
select
(
registry_table
[
Arel
.
star
])
end
def
lfs_
registry_table
def
registry_table
::
Geo
::
LfsObjectRegistry
.
arel_table
end
def
fdw_
lfs_object_
table
def
fdw_table
::
Geo
::
Fdw
::
LfsObject
.
arel_table
end
def
fdw_inner_join_lfs_objects
lfs_
registry_table
.
join
(
fdw_
lfs_object_
table
,
Arel
::
Nodes
::
InnerJoin
)
.
on
(
lfs_registry_table
[
:lfs_object_id
].
eq
(
fdw_lfs_object
_table
[
:id
]))
registry_table
.
join
(
fdw_table
,
Arel
::
Nodes
::
InnerJoin
)
.
on
(
registry_table
[
:lfs_object_id
].
eq
(
fdw
_table
[
:id
]))
.
join_sources
end
end
...
...
ee/spec/models/geo/fdw/lfs_object_spec.rb
View file @
9967fc58
...
...
@@ -8,7 +8,7 @@ RSpec.describe Geo::Fdw::LfsObject, :geo, type: :model do
it
{
is_expected
.
to
have_many
(
:projects
).
class_name
(
'Geo::Fdw::Project'
).
through
(
:lfs_objects_projects
)
}
end
describe
'.missing_
file_
registry'
,
:geo_fdw
do
describe
'.missing_registry'
,
:geo_fdw
do
it
"returns lfs objects that don't have a corresponding registry entry"
do
missing_registry_entries
=
create_list
(
:lfs_object
,
2
)
...
...
@@ -16,7 +16,7 @@ RSpec.describe Geo::Fdw::LfsObject, :geo, type: :model do
create
(
:geo_lfs_object_registry
,
lfs_object_id:
lfs
.
id
)
end
expect
(
described_class
.
missing_
file_
registry
).
to
match_ids
(
missing_registry_entries
)
expect
(
described_class
.
missing_registry
).
to
match_ids
(
missing_registry_entries
)
end
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