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
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
6f6d2d0a
Commit
6f6d2d0a
authored
Apr 13, 2016
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use more conservative limits
parent
bf31b449
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
9 deletions
+9
-9
app/workers/repository_check/batch_worker.rb
app/workers/repository_check/batch_worker.rb
+1
-1
app/workers/repository_check/clear_worker.rb
app/workers/repository_check/clear_worker.rb
+2
-2
spec/workers/repository_check/batch_worker_spec.rb
spec/workers/repository_check/batch_worker_spec.rb
+6
-6
No files found.
app/workers/repository_check/batch_worker.rb
View file @
6f6d2d0a
...
...
@@ -35,7 +35,7 @@ module RepositoryCheck
limit
=
10_000
never_checked_projects
=
Project
.
where
(
'last_repository_check_at IS NULL'
).
limit
(
limit
).
pluck
(
:id
)
old_check_projects
=
Project
.
where
(
'last_repository_check_at < ?'
,
1
.
week
.
ago
).
old_check_projects
=
Project
.
where
(
'last_repository_check_at < ?'
,
1
.
month
.
ago
).
reorder
(
'last_repository_check_at ASC'
).
limit
(
limit
).
pluck
(
:id
)
never_checked_projects
+
old_check_projects
end
...
...
app/workers/repository_check/clear_worker.rb
View file @
6f6d2d0a
...
...
@@ -5,8 +5,8 @@ module RepositoryCheck
sidekiq_options
retry:
false
def
perform
# Do batched updates because these updates will be slow and locking
Project
.
select
(
:id
).
find_in_batches
(
batch_size:
100
0
)
do
|
batch
|
# Do
small
batched updates because these updates will be slow and locking
Project
.
select
(
:id
).
find_in_batches
(
batch_size:
100
)
do
|
batch
|
Project
.
where
(
id:
batch
.
map
(
&
:id
)).
update_all
(
last_repository_check_failed:
nil
,
last_repository_check_at:
nil
,
...
...
spec/workers/repository_check/batch_worker_spec.rb
View file @
6f6d2d0a
...
...
@@ -5,17 +5,17 @@ describe RepositoryCheck::BatchWorker do
it
'prefers projects that have never been checked'
do
projects
=
create_list
(
:project
,
3
)
projects
[
0
].
update_column
(
:last_repository_check_at
,
1
.
month
.
ago
)
projects
[
2
].
update_column
(
:last_repository_check_at
,
3
.
week
s
.
ago
)
projects
[
0
].
update_column
(
:last_repository_check_at
,
4
.
months
.
ago
)
projects
[
2
].
update_column
(
:last_repository_check_at
,
3
.
month
s
.
ago
)
expect
(
subject
.
perform
).
to
eq
(
projects
.
values_at
(
1
,
0
,
2
).
map
(
&
:id
))
end
it
'sorts projects by last_repository_check_at'
do
projects
=
create_list
(
:project
,
3
)
projects
[
0
].
update_column
(
:last_repository_check_at
,
2
.
week
s
.
ago
)
projects
[
1
].
update_column
(
:last_repository_check_at
,
1
.
month
.
ago
)
projects
[
2
].
update_column
(
:last_repository_check_at
,
3
.
week
s
.
ago
)
projects
[
0
].
update_column
(
:last_repository_check_at
,
2
.
month
s
.
ago
)
projects
[
1
].
update_column
(
:last_repository_check_at
,
4
.
months
.
ago
)
projects
[
2
].
update_column
(
:last_repository_check_at
,
3
.
month
s
.
ago
)
expect
(
subject
.
perform
).
to
eq
(
projects
.
values_at
(
1
,
2
,
0
).
map
(
&
:id
))
end
...
...
@@ -23,7 +23,7 @@ describe RepositoryCheck::BatchWorker do
it
'excludes projects that were checked recently'
do
projects
=
create_list
(
:project
,
3
)
projects
[
0
].
update_column
(
:last_repository_check_at
,
2
.
days
.
ago
)
projects
[
1
].
update_column
(
:last_repository_check_at
,
1
.
month
.
ago
)
projects
[
1
].
update_column
(
:last_repository_check_at
,
2
.
months
.
ago
)
projects
[
2
].
update_column
(
:last_repository_check_at
,
3
.
days
.
ago
)
expect
(
subject
.
perform
).
to
eq
([
projects
[
1
].
id
])
...
...
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