Move templates project creation for new team to delayed job [SCI-3101]

This commit is contained in:
Oleksii Kriuchykhin 2019-02-26 13:32:00 +01:00
parent 4da0eab328
commit a0d2f7c676
2 changed files with 11 additions and 8 deletions

View file

@ -315,7 +315,7 @@ class Team < ApplicationRecord
def generate_template_project
return if without_templates
TemplatesService.new.update_team(self)
TemplatesService.new.delay(queue: :templates).update_team(self)
end
include FirstTimeDataGenerator

View file

@ -32,6 +32,8 @@ class TemplatesService
return unless owner.present?
updated = false
exp_tmplt_dir_prefix = "#{@base_dir}/experiment_"
# Create lock in case another worker starts to update same team
tmpl_project.with_lock do
existing = tmpl_project.experiments.where.not(uuid: nil).pluck(:uuid)
@experiment_templates.except(*existing).each_value do |id|
importer_service = TeamImporter.new
@ -40,6 +42,7 @@ class TemplatesService
)
updated = true
end
end
updated
end