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
853e6391
Commit
853e6391
authored
Dec 14, 2021
by
Sean Arnold
Committed by
Douglas Barbosa Alexandre
Jan 05, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add migration to enqueue background worker
Changelog: added
parent
e5bea80c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
0 deletions
+63
-0
db/migrate/20211214012507_backfill_incident_issue_escalation_statuses.rb
...1214012507_backfill_incident_issue_escalation_statuses.rb
+28
-0
db/schema_migrations/20211214012507
db/schema_migrations/20211214012507
+1
-0
spec/migrations/20211214012507_backfill_incident_issue_escalation_statuses_spec.rb
...12507_backfill_incident_issue_escalation_statuses_spec.rb
+34
-0
No files found.
db/migrate/20211214012507_backfill_incident_issue_escalation_statuses.rb
0 → 100644
View file @
853e6391
# frozen_string_literal: true
class
BackfillIncidentIssueEscalationStatuses
<
Gitlab
::
Database
::
Migration
[
1.0
]
MIGRATION
=
'BackfillIncidentIssueEscalationStatuses'
DELAY_INTERVAL
=
2
.
minutes
BATCH_SIZE
=
10_000
disable_ddl_transaction!
class
Issue
<
ActiveRecord
::
Base
include
EachBatch
self
.
table_name
=
'issues'
scope
:incidents
,
->
{
where
(
issue_type:
1
)
}
end
def
up
relation
=
Issue
.
incidents
queue_background_migration_jobs_by_range_at_intervals
(
relation
,
MIGRATION
,
DELAY_INTERVAL
,
batch_size:
BATCH_SIZE
)
end
def
down
# no-op
end
end
db/schema_migrations/20211214012507
0 → 100644
View file @
853e6391
a7aa1ffccce785d365720309e3773f167075a9d06805eea941e6cd47bc918471
\ No newline at end of file
spec/migrations/20211214012507_backfill_incident_issue_escalation_statuses_spec.rb
0 → 100644
View file @
853e6391
# frozen_string_literal: true
require
'spec_helper'
require_migration!
RSpec
.
describe
BackfillIncidentIssueEscalationStatuses
do
let
(
:namespaces
)
{
table
(
:namespaces
)
}
let
(
:projects
)
{
table
(
:projects
)
}
let
(
:issues
)
{
table
(
:issues
)
}
let
(
:namespace
)
{
namespaces
.
create!
(
name:
'foo'
,
path:
'foo'
)
}
let
(
:project
)
{
projects
.
create!
(
namespace_id:
namespace
.
id
)
}
before
do
stub_const
(
"
#{
described_class
.
name
}
::BATCH_SIZE"
,
1
)
end
it
'schedules jobs for incident issues'
do
issues
.
create!
(
project_id:
project
.
id
)
# non-incident issue
incident_1
=
issues
.
create!
(
project_id:
project
.
id
,
issue_type:
1
)
incident_2
=
issues
.
create!
(
project_id:
project
.
id
,
issue_type:
1
)
Sidekiq
::
Testing
.
fake!
do
freeze_time
do
migrate!
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_delayed_migration
(
2
.
minutes
,
incident_1
.
id
,
incident_1
.
id
)
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_delayed_migration
(
4
.
minutes
,
incident_2
.
id
,
incident_2
.
id
)
expect
(
BackgroundMigrationWorker
.
jobs
.
size
).
to
eq
(
2
)
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