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
e8f578d0
Commit
e8f578d0
authored
Oct 23, 2020
by
Arturo Herrero
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract duplicated logic for propagate integrations
parent
4e6e79ec
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
23 deletions
+30
-23
app/services/admin/propagate_integration_service.rb
app/services/admin/propagate_integration_service.rb
+20
-20
app/services/concerns/admin/propagate_service.rb
app/services/concerns/admin/propagate_service.rb
+10
-3
No files found.
app/services/admin/propagate_integration_service.rb
View file @
e8f578d0
...
...
@@ -19,38 +19,38 @@ module Admin
private
def
update_inherited_integrations
Service
.
by_type
(
integration
.
type
).
inherit_from_id
(
integration
.
id
).
each_batch
(
of:
BATCH_SIZE
)
do
|
services
|
min_id
,
max_id
=
services
.
pick
(
"MIN(services.id), MAX(services.id)"
)
PropagateIntegrationInheritWorker
.
perform_async
(
integration
.
id
,
min_id
,
max_id
)
end
propagate_integrations
(
Service
.
by_type
(
integration
.
type
).
inherit_from_id
(
integration
.
id
),
PropagateIntegrationInheritWorker
)
end
def
update_inherited_descendant_integrations
Service
.
inherited_descendants_from_self_or_ancestors_from
(
integration
).
each_batch
(
of:
BATCH_SIZE
)
do
|
services
|
min_id
,
max_id
=
services
.
pick
(
"MIN(services.id), MAX(services.id)"
)
PropagateIntegrationInheritDescendantWorker
.
perform_async
(
integration
.
id
,
min_id
,
max_id
)
end
propagate_integrations
(
Service
.
inherited_descendants_from_self_or_ancestors_from
(
integration
),
PropagateIntegrationInheritDescendantWorker
)
end
def
create_integration_for_groups_without_integration
Group
.
without_integration
(
integration
).
each_batch
(
of:
BATCH_SIZE
)
do
|
groups
|
min_id
,
max_id
=
groups
.
pick
(
"MIN(namespaces.id), MAX(namespaces.id)"
)
PropagateIntegrationGroupWorker
.
perform_async
(
integration
.
id
,
min_id
,
max_id
)
end
propagate_integrations
(
Group
.
without_integration
(
integration
),
PropagateIntegrationGroupWorker
)
end
def
create_integration_for_groups_without_integration_belonging_to_group
integration
.
group
.
descendants
.
without_integration
(
integration
).
each_batch
(
of:
BATCH_SIZE
)
do
|
groups
|
min_id
,
max_id
=
groups
.
pick
(
"MIN(namespaces.id), MAX(namespaces.id)"
)
PropagateIntegrationGroupWorker
.
perform_async
(
integration
.
id
,
min_id
,
max_id
)
end
propagate_integrations
(
integration
.
group
.
descendants
.
without_integration
(
integration
),
PropagateIntegrationGroupWorker
)
end
def
create_integration_for_projects_without_integration_belonging_to_group
Project
.
without_integration
(
integration
).
in_namespace
(
integration
.
group
.
self_and_descendants
).
each_batch
(
of:
BATCH_SIZE
)
do
|
projects
|
min_id
,
max_id
=
projects
.
pick
(
"MIN(projects.id), MAX(projects.id)"
)
PropagateIntegrationProjectWorker
.
perform_async
(
integration
.
id
,
min_id
,
max_id
)
end
propagate_integrations
(
Project
.
without_integration
(
integration
).
in_namespace
(
integration
.
group
.
self_and_descendants
),
PropagateIntegrationProjectWorker
)
end
end
end
app/services/concerns/admin/propagate_service.rb
View file @
e8f578d0
...
...
@@ -21,9 +21,16 @@ module Admin
attr_reader
:integration
def
create_integration_for_projects_without_integration
Project
.
without_integration
(
integration
).
each_batch
(
of:
BATCH_SIZE
)
do
|
projects
|
min_id
,
max_id
=
projects
.
pick
(
"MIN(projects.id), MAX(projects.id)"
)
PropagateIntegrationProjectWorker
.
perform_async
(
integration
.
id
,
min_id
,
max_id
)
propagate_integrations
(
Project
.
without_integration
(
integration
),
PropagateIntegrationProjectWorker
)
end
def
propagate_integrations
(
relation
,
worker_class
)
relation
.
each_batch
(
of:
BATCH_SIZE
)
do
|
records
|
min_id
,
max_id
=
records
.
pick
(
"MIN(
#{
relation
.
table_name
}
.id), MAX(
#{
relation
.
table_name
}
.id)"
)
worker_class
.
perform_async
(
integration
.
id
,
min_id
,
max_id
)
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