From 6e6e68f4f14039a19a770645ac3d22d87f5d99fa Mon Sep 17 00:00:00 2001 From: Devin Gaffney Date: Mon, 19 Aug 2024 09:28:44 -0700 Subject: [PATCH] rename function and revert request --- app/models/concerns/alegre_v2.rb | 4 ++-- app/models/concerns/article.rb | 2 +- app/models/explainer.rb | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/models/concerns/alegre_v2.rb b/app/models/concerns/alegre_v2.rb index cd3e791052..acd2c3ed4b 100644 --- a/app/models/concerns/alegre_v2.rb +++ b/app/models/concerns/alegre_v2.rb @@ -284,11 +284,11 @@ def store_package_text(project_media, field, params) generic_package_text(project_media, field, params) end - def get_sync_raw_params(params, type) + def get_sync_with_params(params, type) request("post", sync_path_for_type(type), params) end - def get_async_raw_params(params, type) + def get_async_with_params(params, type) request("post", async_path_for_type(type), params) end diff --git a/app/models/concerns/article.rb b/app/models/concerns/article.rb index 3cfafc5dda..e4b1ed48be 100644 --- a/app/models/concerns/article.rb +++ b/app/models/concerns/article.rb @@ -84,7 +84,7 @@ def send_to_alegre(id) obj = self.find_by_id(id) return if obj.project_media.nil? obj.text_fields.each do |field| - ::Bot::Alegre.relate_project_media_async(obj.project_media, field) + ::Bot::Alegre.send_field_to_similarity_index(obj.project_media, field) end unless obj.nil? end end diff --git a/app/models/explainer.rb b/app/models/explainer.rb index 3ac3e05a71..9cabd15f48 100644 --- a/app/models/explainer.rb +++ b/app/models/explainer.rb @@ -69,7 +69,7 @@ def self.update_paragraphs_in_alegre(id, previous_paragraphs_count, timestamp) text: explainer.title, models: ALEGRE_MODELS_AND_THRESHOLDS.keys, } - Bot::Alegre.get_sync_raw_params(params, "text") + Bot::Alegre.get_sync_with_params(params, "text") # Index paragraphs count = 0 @@ -82,7 +82,7 @@ def self.update_paragraphs_in_alegre(id, previous_paragraphs_count, timestamp) text: paragraph.strip, models: ALEGRE_MODELS_AND_THRESHOLDS.keys, } - Bot::Alegre.get_sync_raw_params(params, "text") + Bot::Alegre.get_sync_with_params(params, "text") end # Remove paragraphs that don't exist anymore (we delete after updating in order to avoid race conditions) @@ -108,7 +108,7 @@ def self.search_by_similarity(text, language, team_id) language: language } } - response = Bot::Alegre.get_sync_raw_params(params, "text") + response = Bot::Alegre.get_sync_with_params(params, "text") results = response['result'].to_a.sort_by{ |result| result['_score'] } explainer_ids = results.collect{ |result| result.dig('_source', 'context', 'explainer_id').to_i }.uniq.first(3) explainer_ids.empty? ? Explainer.none : Explainer.where(team_id: team_id, id: explainer_ids)