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
1c672dca
Commit
1c672dca
authored
Nov 27, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring Geo::ProjectRegistryFinder
parent
ca2a8ce4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
10 deletions
+12
-10
app/finders/geo/project_registry_finder.rb
app/finders/geo/project_registry_finder.rb
+12
-10
No files found.
app/finders/geo/project_registry_finder.rb
View file @
1c672dca
...
@@ -7,10 +7,8 @@ module Geo
...
@@ -7,10 +7,8 @@ module Geo
end
end
def
find_unsynced_projects
(
batch_size
:)
def
find_unsynced_projects
(
batch_size
:)
# Selective project replication adds a wrinkle to FDW queries, so
# we fallback to the legacy version for now.
relation
=
relation
=
if
Gitlab
::
Geo
.
fdw?
&&
!
selective_sync
if
fdw?
fdw_find_unsynced_projects
fdw_find_unsynced_projects
else
else
legacy_find_unsynced_projects
legacy_find_unsynced_projects
...
@@ -20,10 +18,8 @@ module Geo
...
@@ -20,10 +18,8 @@ module Geo
end
end
def
find_projects_updated_recently
(
batch_size
:)
def
find_projects_updated_recently
(
batch_size
:)
# Selective project replication adds a wrinkle to FDW queries, so
# we fallback to the legacy version for now.
relation
=
relation
=
if
Gitlab
::
Geo
.
fdw?
&&
!
selective_sync
if
fdw?
fdw_find_projects_updated_recently
fdw_find_projects_updated_recently
else
else
legacy_find_projects_updated_recently
legacy_find_projects_updated_recently
...
@@ -34,6 +30,16 @@ module Geo
...
@@ -34,6 +30,16 @@ module Geo
protected
protected
def
fdw?
# Selective project replication adds a wrinkle to FDW
# queries, so we fallback to the legacy version for now.
Gitlab
::
Geo
.
fdw?
&&
!
selective_sync
end
def
fdw_table
Geo
::
Fdw
::
Project
.
table_name
end
def
selective_sync
def
selective_sync
current_node
.
restricted_project_ids
current_node
.
restricted_project_ids
end
end
...
@@ -44,16 +50,12 @@ module Geo
...
@@ -44,16 +50,12 @@ module Geo
# @return [ActiveRecord::Relation<Geo::Fdw::Project>]
# @return [ActiveRecord::Relation<Geo::Fdw::Project>]
def
fdw_find_unsynced_projects
def
fdw_find_unsynced_projects
fdw_table
=
Geo
::
Fdw
::
Project
.
table_name
Geo
::
Fdw
::
Project
.
joins
(
"LEFT OUTER JOIN project_registry ON project_registry.project_id =
#{
fdw_table
}
.id"
)
Geo
::
Fdw
::
Project
.
joins
(
"LEFT OUTER JOIN project_registry ON project_registry.project_id =
#{
fdw_table
}
.id"
)
.
where
(
'project_registry.project_id IS NULL'
)
.
where
(
'project_registry.project_id IS NULL'
)
end
end
# @return [ActiveRecord::Relation<Geo::Fdw::Project>]
# @return [ActiveRecord::Relation<Geo::Fdw::Project>]
def
fdw_find_projects_updated_recently
def
fdw_find_projects_updated_recently
fdw_table
=
Geo
::
Fdw
::
Project
.
table_name
Geo
::
Fdw
::
Project
.
joins
(
"INNER JOIN project_registry ON project_registry.project_id =
#{
fdw_table
}
.id"
)
Geo
::
Fdw
::
Project
.
joins
(
"INNER JOIN project_registry ON project_registry.project_id =
#{
fdw_table
}
.id"
)
.
merge
(
Geo
::
ProjectRegistry
.
dirty
)
.
merge
(
Geo
::
ProjectRegistry
.
dirty
)
.
merge
(
Geo
::
ProjectRegistry
.
retry_due
)
.
merge
(
Geo
::
ProjectRegistry
.
retry_due
)
...
...
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