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
134f204e
Commit
134f204e
authored
Jun 30, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not override original AR5 batching interface
parent
6997dfa3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
4 deletions
+7
-4
config/initializers/ar5_batching.rb
config/initializers/ar5_batching.rb
+2
-2
db/post_migrate/20170628080858_migrate_stage_id_reference_in_background.rb
...0170628080858_migrate_stage_id_reference_in_background.rb
+5
-2
No files found.
config/initializers/ar5_batching.rb
View file @
134f204e
...
@@ -15,7 +15,7 @@ module ActiveRecord
...
@@ -15,7 +15,7 @@ module ActiveRecord
relation
=
relation
.
where
(
arel_table
[
primary_key
].
lteq
(
finish
))
if
finish
relation
=
relation
.
where
(
arel_table
[
primary_key
].
lteq
(
finish
))
if
finish
batch_relation
=
relation
batch_relation
=
relation
1
.
step
do
|
index
|
loop
do
if
load
if
load
records
=
batch_relation
.
records
records
=
batch_relation
.
records
ids
=
records
.
map
(
&
:id
)
ids
=
records
.
map
(
&
:id
)
...
@@ -31,7 +31,7 @@ module ActiveRecord
...
@@ -31,7 +31,7 @@ module ActiveRecord
primary_key_offset
=
ids
.
last
primary_key_offset
=
ids
.
last
raise
ArgumentError
.
new
(
"Primary key not included in the custom select clause"
)
unless
primary_key_offset
raise
ArgumentError
.
new
(
"Primary key not included in the custom select clause"
)
unless
primary_key_offset
yield
yielded_relation
,
index
yield
yielded_relation
break
if
ids
.
length
<
of
break
if
ids
.
length
<
of
batch_relation
=
relation
.
where
(
arel_table
[
primary_key
].
gt
(
primary_key_offset
))
batch_relation
=
relation
.
where
(
arel_table
[
primary_key
].
gt
(
primary_key_offset
))
...
...
db/post_migrate/20170628080858_migrate_stage_id_reference_in_background.rb
View file @
134f204e
...
@@ -12,9 +12,12 @@ class MigrateStageIdReferenceInBackground < ActiveRecord::Migration
...
@@ -12,9 +12,12 @@ class MigrateStageIdReferenceInBackground < ActiveRecord::Migration
end
end
def
up
def
up
Build
.
where
(
stage_id:
nil
).
in_batches
(
of:
BATCH_SIZE
)
do
|
relation
,
index
|
index
=
1
schedule
=
index
*
5
.
minutes
Build
.
where
(
stage_id:
nil
).
in_batches
(
of:
BATCH_SIZE
)
do
|
relation
|
jobs
=
relation
.
pluck
(
:id
).
map
{
|
id
|
[
MIGRATION
,
[
id
]]
}
jobs
=
relation
.
pluck
(
:id
).
map
{
|
id
|
[
MIGRATION
,
[
id
]]
}
schedule
=
index
*
5
.
minutes
index
+=
1
BackgroundMigrationWorker
.
perform_bulk_in
(
schedule
,
jobs
)
BackgroundMigrationWorker
.
perform_bulk_in
(
schedule
,
jobs
)
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