mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-01 13:13:22 +08:00
Merge pull request #1527 from okriuchykhin/ok_SCI_3101
Move templates project creation for new team to delayed job [SCI-3101]
This commit is contained in:
commit
985820a97c
2 changed files with 11 additions and 8 deletions
|
@ -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
|
||||
|
|
|
@ -32,13 +32,16 @@ class TemplatesService
|
|||
return unless owner.present?
|
||||
updated = false
|
||||
exp_tmplt_dir_prefix = "#{@base_dir}/experiment_"
|
||||
existing = tmpl_project.experiments.where.not(uuid: nil).pluck(:uuid)
|
||||
@experiment_templates.except(*existing).each_value do |id|
|
||||
importer_service = TeamImporter.new
|
||||
importer_service.import_experiment_template_from_dir(
|
||||
exp_tmplt_dir_prefix + id.to_s, tmpl_project.id, owner.id
|
||||
)
|
||||
updated = true
|
||||
# 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
|
||||
importer_service.import_experiment_template_from_dir(
|
||||
exp_tmplt_dir_prefix + id.to_s, tmpl_project.id, owner.id
|
||||
)
|
||||
updated = true
|
||||
end
|
||||
end
|
||||
updated
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue