Skip to content

Commit

Permalink
Updates Tag creation to not send the entire object
Browse files Browse the repository at this point in the history
I'm unsure if it's ok to change this, but looking in our GraphQL wiki we
should be able to create a Tag by sending the annotated_type and id.

If we update create_tags to send those two values instead of the entire
object, we are able to do it in the background job.
  • Loading branch information
vasconsaurus committed Aug 27, 2024
1 parent b7d5a86 commit f2f0bca
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
5 changes: 1 addition & 4 deletions app/models/concerns/project_media_creators.rb
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,6 @@ def create_claim_description_and_fact_check
end

def create_tags
# self.set_tags.each { |tag| Tag.create!(annotated: self, tag: tag.strip, skip_check_ability: true) } if self.set_tags.is_a?(Array)
# require 'byebug'
# byebug
self.set_tags.each { |tag| GenericWorker.perform_in(1.second, 'Tag', 'create!', annotated: self, tag: tag.strip, skip_check_ability: true) } if self.set_tags.is_a?(Array)
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)
end
end
2 changes: 1 addition & 1 deletion test/workers/generic_worker_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def setup
pm = create_project_media project: p

assert_nothing_raised do
GenericWorker.perform_async('Tag', 'create!', annotated: pm, tag: 'test_tag', skip_check_ability: true)
GenericWorker.perform_async('Tag', 'create!', annotated_type: 'ProjectMedia' , annotated_id: pm.id, tag: 'test_tag', skip_check_ability: true)
end
end

Expand Down

0 comments on commit f2f0bca

Please sign in to comment.