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
1f2d7bd3
Commit
1f2d7bd3
authored
Nov 29, 2018
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename the finder methods to make clear its real intent
parent
5da58325
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
107 deletions
+65
-107
ee/app/finders/geo/repository_verification_finder.rb
ee/app/finders/geo/repository_verification_finder.rb
+15
-21
ee/app/workers/geo/repository_verification/primary/shard_worker.rb
...rkers/geo/repository_verification/primary/shard_worker.rb
+6
-6
ee/spec/finders/geo/repository_verification_finder_spec.rb
ee/spec/finders/geo/repository_verification_finder_spec.rb
+44
-80
No files found.
ee/app/finders/geo/repository_verification_finder.rb
View file @
1f2d7bd3
...
...
@@ -29,9 +29,9 @@ module Geo
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def
find_
out
dated_projects
(
batch_size
:)
query
=
build_query_to_find_
out
dated_projects
(
batch_size:
batch_size
)
cte
=
Gitlab
::
SQL
::
CTE
.
new
(
:
out
dated_projects
,
query
)
def
find_
recently_up
dated_projects
(
batch_size
:)
query
=
build_query_to_find_
recently_up
dated_projects
(
batch_size:
batch_size
)
cte
=
Gitlab
::
SQL
::
CTE
.
new
(
:
recently_up
dated_projects
,
query
)
Project
.
with
(
cte
.
to_arel
)
.
from
(
cte
.
alias_to
(
projects_table
))
...
...
@@ -40,12 +40,12 @@ module Geo
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def
find_
un
verified_projects
(
batch_size
:)
def
find_
never_
verified_projects
(
batch_size
:)
relation
=
Project
.
select
(
:id
)
.
with_route
.
joins
(
left_join_repository_state
)
.
where
(
repository_
never_verified
)
.
where
(
repository_
state_table
[
:project_id
].
eq
(
nil
)
)
.
limit
(
batch_size
)
apply_shard_restriction
(
relation
)
...
...
@@ -96,12 +96,20 @@ module Geo
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def
build_query_to_find_outdated_projects
(
batch_size
:)
def
build_query_to_find_recently_updated_projects
(
batch_size
:)
repository_recently_updated
=
repository_state_table
[
:repository_verification_checksum
].
eq
(
nil
)
.
and
(
repository_state_table
[
:last_repository_verification_failure
].
eq
(
nil
))
wiki_recently_updated
=
repository_state_table
[
:wiki_verification_checksum
].
eq
(
nil
)
.
and
(
repository_state_table
[
:last_wiki_verification_failure
].
eq
(
nil
))
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_out
dated
))
.
where
(
repository_
recently_updated
.
or
(
wiki_recently_up
dated
))
.
take
(
batch_size
)
apply_shard_restriction
(
query
)
...
...
@@ -149,20 +157,6 @@ module Geo
.
join_sources
end
def
repository_outdated
repository_state_table
[
:repository_verification_checksum
].
eq
(
nil
)
.
and
(
repository_state_table
[
:last_repository_verification_failure
].
eq
(
nil
))
end
def
wiki_outdated
repository_state_table
[
:wiki_verification_checksum
].
eq
(
nil
)
.
and
(
repository_state_table
[
:last_wiki_verification_failure
].
eq
(
nil
))
end
def
repository_never_verified
repository_state_table
[
:project_id
].
eq
(
nil
)
end
def
last_repository_updated_at_asc
Gitlab
::
Database
.
nulls_last_order
(
'projects.last_repository_updated_at'
,
'ASC'
)
end
...
...
ee/app/workers/geo/repository_verification/primary/shard_worker.rb
View file @
1f2d7bd3
...
...
@@ -44,11 +44,11 @@ module Geo
end
def
load_pending_resources
resources
=
find_
un
verified_project_ids
(
batch_size:
db_retrieve_batch_size
)
resources
=
find_
never_
verified_project_ids
(
batch_size:
db_retrieve_batch_size
)
remaining_capacity
=
db_retrieve_batch_size
-
resources
.
size
return
resources
if
remaining_capacity
.
zero?
resources
+=
find_
out
dated_project_ids
(
batch_size:
remaining_capacity
)
resources
+=
find_
recently_up
dated_project_ids
(
batch_size:
remaining_capacity
)
remaining_capacity
=
db_retrieve_batch_size
-
resources
.
size
return
resources
if
remaining_capacity
.
zero?
...
...
@@ -56,14 +56,14 @@ module Geo
end
# rubocop: disable CodeReuse/ActiveRecord
def
find_
un
verified_project_ids
(
batch_size
:)
finder
.
find_
un
verified_projects
(
batch_size:
batch_size
).
pluck
(
:id
)
def
find_
never_
verified_project_ids
(
batch_size
:)
finder
.
find_
never_
verified_projects
(
batch_size:
batch_size
).
pluck
(
:id
)
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def
find_
out
dated_project_ids
(
batch_size
:)
finder
.
find_
out
dated_projects
(
batch_size:
batch_size
).
pluck
(
:id
)
def
find_
recently_up
dated_project_ids
(
batch_size
:)
finder
.
find_
recently_up
dated_projects
(
batch_size:
batch_size
).
pluck
(
:id
)
end
# rubocop: enable CodeReuse/ActiveRecord
...
...
ee/spec/finders/geo/repository_verification_finder_spec.rb
View file @
1f2d7bd3
This diff is collapsed.
Click to expand it.
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