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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
adcff298
Commit
adcff298
authored
May 05, 2017
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed all issues - not doing bulk create.
parent
1fe8b7f6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
7 deletions
+15
-7
app/services/projects/propagate_service.rb
app/services/projects/propagate_service.rb
+3
-7
spec/services/projects/propagate_service_spec.rb
spec/services/projects/propagate_service_spec.rb
+12
-0
No files found.
app/services/projects/propagate_service.rb
View file @
adcff298
...
@@ -21,16 +21,12 @@ module Projects
...
@@ -21,16 +21,12 @@ module Projects
private
private
def
propagate_projects_with_template
def
propagate_projects_with_template
offset
=
0
loop
do
loop
do
batch
=
project_ids_batch
(
offset
)
batch
=
project_ids_batch
bulk_create_from_template
(
batch
)
bulk_create_from_template
(
batch
)
break
if
batch
.
size
<
BATCH_SIZE
break
if
batch
.
size
<
BATCH_SIZE
offset
+=
BATCH_SIZE
end
end
end
end
...
@@ -44,7 +40,7 @@ module Projects
...
@@ -44,7 +40,7 @@ module Projects
end
end
end
end
def
project_ids_batch
(
offset
)
def
project_ids_batch
Project
.
connection
.
execute
(
Project
.
connection
.
execute
(
<<-
SQL
<<-
SQL
SELECT id
SELECT id
...
@@ -55,7 +51,7 @@ module Projects
...
@@ -55,7 +51,7 @@ module Projects
WHERE services.project_id = projects.id
WHERE services.project_id = projects.id
AND services.type = '
#{
@template
.
type
}
'
AND services.type = '
#{
@template
.
type
}
'
)
)
LIMIT
#{
BATCH_SIZE
}
OFFSET
#{
offset
}
LIMIT
#{
BATCH_SIZE
}
SQL
SQL
).
to_a
.
flatten
).
to_a
.
flatten
end
end
...
...
spec/services/projects/propagate_service_spec.rb
View file @
adcff298
...
@@ -66,5 +66,17 @@ describe Projects::PropagateService, services: true do
...
@@ -66,5 +66,17 @@ describe Projects::PropagateService, services: true do
expect
(
service
.
properties
).
to
eq
(
service_template
.
properties
)
expect
(
service
.
properties
).
to
eq
(
service_template
.
properties
)
end
end
describe
'bulk update'
do
it
'creates services for all projects'
do
project_total
=
5
stub_const
'Projects::PropagateService::BATCH_SIZE'
,
3
project_total
.
times
{
create
(
:empty_project
)
}
expect
{
described_class
.
propagate
(
service_template
)
}.
to
change
{
Service
.
count
}.
by
(
project_total
+
1
)
end
end
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