diff options
author | James Lopez <james@jameslopez.es> | 2017-05-05 16:16:02 +0200 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2017-05-05 16:16:02 +0200 |
commit | ce418036c763219df8239632f71ef0e9782be7ea (patch) | |
tree | ca19e128f5e5e0025424fd77db178a3837075b68 /app/services | |
parent | 606584c115d5f7a22f3b5c7e0ac6803b96fe999e (diff) | |
download | gitlab-ce-ce418036c763219df8239632f71ef0e9782be7ea.tar.gz |
add callbacks in bulk
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/projects/propagate_service.rb | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/app/services/projects/propagate_service.rb b/app/services/projects/propagate_service.rb index c420f24fe02..f4fae478609 100644 --- a/app/services/projects/propagate_service.rb +++ b/app/services/projects/propagate_service.rb @@ -35,12 +35,12 @@ module Projects service_hash.merge('project_id' => project_id).values end - # Project.transaction do - # Service.create!(service_hash_list) - # end - Gitlab::SQL::BulkInsert.new(service_hash.keys + ['project_id'], - service_list, - 'services').execute + Project.transaction do + Gitlab::SQL::BulkInsert.new(service_hash.keys + ['project_id'], + service_list, + 'services').execute + run_callbacks(batch) + end end def project_ids_batch @@ -72,5 +72,23 @@ module Projects end end end + + def run_callbacks(batch) + if active_external_issue_tracker? + Project.where(id: batch).update_all(has_external_issue_tracker: true) + end + + if active_external_wiki? + Project.where(id: batch).update_all(has_external_wiki: true) + end + end + + def active_external_issue_tracker? + @template['category'] == 'issue_tracker' && @template['active'] && !@template['default'] + end + + def active_external_wiki? + @template['type'] == 'ExternalWikiService' && @template['active'] + end end end |