diff --git a/app/models/bot/alegre.rb b/app/models/bot/alegre.rb index eecd91db14..5ce586ce31 100644 --- a/app/models/bot/alegre.rb +++ b/app/models/bot/alegre.rb @@ -221,8 +221,8 @@ def self.get_number_of_words(text) def self.get_items_from_similar_text(team_id, text, fields = nil, threshold = nil, models = nil, fuzzy = false) team_ids = [team_id].flatten - if text.blank? || self.get_number_of_words(text) < 3 - Rails.logger.info("[Alegre Bot] get_items_from_similar_text returning early due to blank/short text #{text}") + if text.blank? + Rails.logger.info("[Alegre Bot] get_items_from_similar_text returning early due to blank text #{text}") return {} end fields ||= ALL_TEXT_SIMILARITY_FIELDS diff --git a/test/models/bot/alegre_2_test.rb b/test/models/bot/alegre_2_test.rb index 1e26a8045f..74e8a0f9c0 100644 --- a/test/models/bot/alegre_2_test.rb +++ b/test/models/bot/alegre_2_test.rb @@ -553,8 +553,8 @@ def teardown TeamBotInstallation.unstub(:find_by_team_id_and_user_id) end - test "should not get similar texts for texts with up to 2 words" do - assert_equal({}, Bot::Alegre.get_items_from_similar_text(random_number, 'Foo bar')) + test "should not get similar texts for blank string" do + assert_equal({}, Bot::Alegre.get_items_from_similar_text(random_number, '')) end test "should match rule by extracted text" do @@ -620,10 +620,11 @@ def teardown "sha256" => "1782b1d1993fcd9f6fd8155adc6009a9693a8da7bb96d20270c4bc8a30c97570", "phash" => 17399941807326929, "url" => "https:\/\/www.gstatic.com\/webp\/gallery3\/1.png", - "context" => [{ + "context" => { "team_id" => pm2.team.id.to_s, - "project_media_id" => pm2.id.to_s - }], + "project_media_id" => pm2.id.to_s, + "field" => "title" + }, }, "_score" => 0.9 }