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
5b9b61d7
Commit
5b9b61d7
authored
Sep 07, 2020
by
Arturo Herrero
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve naming when batch is batch_ids
parent
a359d510
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
22 deletions
+22
-22
app/models/service_list.rb
app/models/service_list.rb
+4
-4
app/services/admin/propagate_integration_service.rb
app/services/admin/propagate_integration_service.rb
+9
-9
app/services/admin/propagate_service_template.rb
app/services/admin/propagate_service_template.rb
+9
-9
No files found.
app/models/service_list.rb
View file @
5b9b61d7
# frozen_string_literal: true
class
ServiceList
def
initialize
(
batch
,
service_hash
)
@batch
=
batch
def
initialize
(
batch
_ids
,
service_hash
)
@batch
_ids
=
batch_ids
@service_hash
=
service_hash
end
...
...
@@ -12,14 +12,14 @@ class ServiceList
private
attr_reader
:batch
,
:service_hash
attr_reader
:batch
_ids
,
:service_hash
def
columns
(
service_hash
.
keys
<<
'project_id'
)
end
def
values
batch
.
map
do
|
project_id
|
batch
_ids
.
map
do
|
project_id
|
(
service_hash
.
values
<<
project_id
)
end
end
...
...
app/services/admin/propagate_integration_service.rb
View file @
5b9b61d7
...
...
@@ -52,16 +52,16 @@ module Admin
def
create_integration_for_projects_without_integration
loop
do
batch
=
Project
.
uncached
{
Project
.
ids_without_integration
(
integration
,
BATCH_SIZE
)
}
batch
_ids
=
Project
.
uncached
{
Project
.
ids_without_integration
(
integration
,
BATCH_SIZE
)
}
bulk_create_from_integration
(
batch
)
unless
batch
.
empty?
bulk_create_from_integration
(
batch
_ids
)
unless
batch_ids
.
empty?
break
if
batch
.
size
<
BATCH_SIZE
break
if
batch
_ids
.
size
<
BATCH_SIZE
end
end
def
bulk_create_from_integration
(
batch
)
service_list
=
ServiceList
.
new
(
batch
,
service_hash
).
to_array
def
bulk_create_from_integration
(
batch
_ids
)
service_list
=
ServiceList
.
new
(
batch
_ids
,
service_hash
).
to_array
Project
.
transaction
do
results
=
bulk_insert
(
*
service_list
)
...
...
@@ -72,7 +72,7 @@ module Admin
bulk_insert
(
*
data_list
)
end
run_callbacks
(
batch
)
run_callbacks
(
batch
_ids
)
end
end
...
...
@@ -83,13 +83,13 @@ module Admin
end
# rubocop: disable CodeReuse/ActiveRecord
def
run_callbacks
(
batch
)
def
run_callbacks
(
batch
_ids
)
if
integration
.
issue_tracker?
Project
.
where
(
id:
batch
).
update_all
(
has_external_issue_tracker:
true
)
Project
.
where
(
id:
batch
_ids
).
update_all
(
has_external_issue_tracker:
true
)
end
if
active_external_wiki?
Project
.
where
(
id:
batch
).
update_all
(
has_external_wiki:
true
)
Project
.
where
(
id:
batch
_ids
).
update_all
(
has_external_wiki:
true
)
end
end
# rubocop: enable CodeReuse/ActiveRecord
...
...
app/services/admin/propagate_service_template.rb
View file @
5b9b61d7
...
...
@@ -26,16 +26,16 @@ module Admin
def
propagate_projects_with_template
loop
do
batch
=
Project
.
uncached
{
Project
.
ids_without_integration
(
template
,
BATCH_SIZE
)
}
batch
_ids
=
Project
.
uncached
{
Project
.
ids_without_integration
(
template
,
BATCH_SIZE
)
}
bulk_create_from_template
(
batch
)
unless
batch
.
empty?
bulk_create_from_template
(
batch
_ids
)
unless
batch_ids
.
empty?
break
if
batch
.
size
<
BATCH_SIZE
break
if
batch
_ids
.
size
<
BATCH_SIZE
end
end
def
bulk_create_from_template
(
batch
)
service_list
=
ServiceList
.
new
(
batch
,
service_hash
).
to_array
def
bulk_create_from_template
(
batch
_ids
)
service_list
=
ServiceList
.
new
(
batch
_ids
,
service_hash
).
to_array
Project
.
transaction
do
results
=
bulk_insert
(
*
service_list
)
...
...
@@ -46,7 +46,7 @@ module Admin
bulk_insert
(
*
data_list
)
end
run_callbacks
(
batch
)
run_callbacks
(
batch
_ids
)
end
end
...
...
@@ -65,13 +65,13 @@ module Admin
end
# rubocop: disable CodeReuse/ActiveRecord
def
run_callbacks
(
batch
)
def
run_callbacks
(
batch
_ids
)
if
template
.
issue_tracker?
Project
.
where
(
id:
batch
).
update_all
(
has_external_issue_tracker:
true
)
Project
.
where
(
id:
batch
_ids
).
update_all
(
has_external_issue_tracker:
true
)
end
if
active_external_wiki?
Project
.
where
(
id:
batch
).
update_all
(
has_external_wiki:
true
)
Project
.
where
(
id:
batch
_ids
).
update_all
(
has_external_wiki:
true
)
end
end
# rubocop: enable CodeReuse/ActiveRecord
...
...
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