diff --git a/app/models/concerns/project_media_creators.rb b/app/models/concerns/project_media_creators.rb index 4262f0140..0fb58650b 100644 --- a/app/models/concerns/project_media_creators.rb +++ b/app/models/concerns/project_media_creators.rb @@ -263,6 +263,8 @@ def create_claim_description_and_fact_check end def create_tags - self.set_tags.each { |tag| GenericWorker.perform_in(1.second, 'Tag', 'create!', annotated_type: 'ProjectMedia' , annotated_id: self.id, tag: tag.strip, skip_check_ability: true) } if self.set_tags.is_a?(Array) + if self.set_tags.is_a?(Array) + GenericWorker.perform_in(1.second, 'ProjectMedia', 'create_tags_in_background', project_media_id: self.id, tags_json: self.set_tags.to_json) + end end end diff --git a/app/models/project_media.rb b/app/models/project_media.rb index 534b50669..b85e08dd0 100644 --- a/app/models/project_media.rb +++ b/app/models/project_media.rb @@ -485,6 +485,13 @@ def add_nested_objects(ms) ms.attributes[:requests] = requests end + + def self.create_tags_in_background(**params) + project_media = ProjectMedia.find(params['project_media_id']) + tags = JSON.parse(params['tags_json']) + tags.each { |tag| Tag.create! annotated: project_media, tag: tag.strip, skip_check_ability: true } + end + # private # # Please add private methods to app/models/concerns/project_media_private.rb