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
78fc9606
Commit
78fc9606
authored
Jun 08, 2018
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor Geo::RepositoryVerificationFinder#find_outdated_projects
parent
9c654efc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
24 deletions
+21
-24
ee/app/finders/geo/repository_verification_finder.rb
ee/app/finders/geo/repository_verification_finder.rb
+21
-24
No files found.
ee/app/finders/geo/repository_verification_finder.rb
View file @
78fc9606
module
Geo
module
Geo
class
RepositoryVerificationFinder
class
RepositoryVerificationFinder
attr_reader
:shard_name
def
initialize
(
shard_name:
nil
)
def
initialize
(
shard_name:
nil
)
@shard_name
=
shard_name
@shard_name
=
shard_name
end
end
def
find_outdated_projects
(
batch_size
:)
def
find_outdated_projects
(
batch_size
:)
cte_definition
=
query
=
build_query_to_find_outdated_projects
(
batch_size:
batch_size
)
projects_table
cte
=
Gitlab
::
SQL
::
CTE
.
new
(
:outdated_projects
,
query
)
.
join
(
repository_state_table
).
on
(
project_id_matcher
)
.
project
(
projects_table
[
:id
],
projects_table
[
:last_repository_updated_at
])
.
where
(
repository_outdated
.
or
(
wiki_outdated
))
.
take
(
batch_size
)
if
shard_name
.
present?
cte_definition
=
shard_restriction
(
cte_definition
)
end
cte_table
=
Arel
::
Table
.
new
(
:outdated_projects
)
Project
.
with
(
cte
.
to_arel
)
composed_cte
=
Arel
::
Nodes
::
As
.
new
(
cte_table
,
cte_definition
)
.
from
(
cte
.
alias_to
(
projects_table
))
alias_to
=
Arel
::
Nodes
::
As
.
new
(
cte_table
,
projects_table
)
Project
.
with
(
composed_cte
)
.
from
(
alias_to
)
.
order
(
last_repository_updated_at_asc
)
.
order
(
last_repository_updated_at_asc
)
end
end
...
@@ -35,10 +21,7 @@ module Geo
...
@@ -35,10 +21,7 @@ module Geo
.
where
(
repository_never_verified
)
.
where
(
repository_never_verified
)
.
limit
(
batch_size
)
.
limit
(
batch_size
)
if
shard_name
.
present?
relation
=
apply_shard_restriction
(
relation
)
if
shard_name
.
present?
relation
=
shard_restriction
(
relation
)
end
relation
relation
end
end
...
@@ -58,7 +41,21 @@ module Geo
...
@@ -58,7 +41,21 @@ module Geo
Project
.
verification_failed_wikis
.
count
Project
.
verification_failed_wikis
.
count
end
end
protected
private
attr_reader
:shard_name
def
build_query_to_find_outdated_projects
(
batch_size
:)
query
=
projects_table
.
join
(
repository_state_table
).
on
(
project_id_matcher
)
.
project
(
projects_table
[
:id
],
projects_table
[
:last_repository_updated_at
])
.
where
(
repository_outdated
.
or
(
wiki_outdated
))
.
take
(
batch_size
)
query
=
apply_shard_restriction
(
query
)
if
shard_name
.
present?
query
end
def
projects_table
def
projects_table
Project
.
arel_table
Project
.
arel_table
...
@@ -97,7 +94,7 @@ module Geo
...
@@ -97,7 +94,7 @@ module Geo
Gitlab
::
Database
.
nulls_last_order
(
'projects.last_repository_updated_at'
,
'ASC'
)
Gitlab
::
Database
.
nulls_last_order
(
'projects.last_repository_updated_at'
,
'ASC'
)
end
end
def
shard_restriction
(
relation
)
def
apply_
shard_restriction
(
relation
)
relation
.
where
(
projects_table
[
:repository_storage
].
eq
(
shard_name
))
relation
.
where
(
projects_table
[
:repository_storage
].
eq
(
shard_name
))
end
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