Skip to content

Commit

Permalink
switch the methods' names
Browse files Browse the repository at this point in the history
I think the method that was called 'in_background' is actually foreground
and vice-versa.
  • Loading branch information
vasconsaurus committed Sep 12, 2024
1 parent bf6686a commit 49f71c0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/models/concerns/project_media_creators.rb
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,9 @@ def create_claim_description_and_fact_check
fc
end

def create_tags
def create_tags_in_background
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, user_id: self.user_id)
GenericWorker.perform_in(1.second, 'ProjectMedia', 'create_tags', project_media_id: self.id, tags_json: self.set_tags.to_json, user_id: self.user_id)
end
end
end
4 changes: 2 additions & 2 deletions app/models/project_media.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ProjectMedia < ApplicationRecord

before_validation :set_team_id, :set_channel, :set_project_id, on: :create
before_validation :create_original_claim, if: proc { |pm| pm.set_original_claim.present? }, on: :create
after_create :create_annotation, :create_metrics_annotation, :send_slack_notification, :create_relationship, :create_team_tasks, :create_claim_description_and_fact_check, :create_tags
after_create :create_annotation, :create_metrics_annotation, :send_slack_notification, :create_relationship, :create_team_tasks, :create_claim_description_and_fact_check, :create_tags_in_background
after_create :add_source_creation_log, unless: proc { |pm| pm.source_id.blank? }
after_commit :apply_rules_and_actions_on_create, :set_quote_metadata, :notify_team_bots_create, on: [:create]
after_commit :create_relationship, on: [:update]
Expand Down Expand Up @@ -528,7 +528,7 @@ def add_nested_objects(ms)
ms.attributes[:requests] = requests
end

def self.create_tags_in_background(**params)
def self.create_tags(**params)
params = params.with_indifferent_access
project_media = ProjectMedia.find_by_id(params['project_media_id'])

Expand Down
4 changes: 2 additions & 2 deletions test/models/project_media_8_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ def setup
pm = create_project_media project: p

assert_nothing_raised do
ProjectMedia.create_tags_in_background(project_media_id: pm.id, tags_json: ['one', 'two'].to_json)
ProjectMedia.create_tags(project_media_id: pm.id, tags_json: ['one', 'two'].to_json)
end
assert_equal 2, pm.annotations('tag').count
end

test "does not raise an error when no project media is sent" do
assert_nothing_raised do
CheckSentry.expects(:notify).once
ProjectMedia.create_tags_in_background(project_media_id: nil, tags_json: ['one', 'two'].to_json)
ProjectMedia.create_tags(project_media_id: nil, tags_json: ['one', 'two'].to_json)
end
end

Expand Down

0 comments on commit 49f71c0

Please sign in to comment.