From 21d37bff311e3987e63cc4200e25e5bb8bc2648e Mon Sep 17 00:00:00 2001 From: Sawy Date: Sun, 15 Dec 2024 10:17:09 +0200 Subject: [PATCH] CV2-5779: use same sort for explainer --- app/models/explainer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/explainer.rb b/app/models/explainer.rb index feee0df35..b26f247eb 100644 --- a/app/models/explainer.rb +++ b/app/models/explainer.rb @@ -117,7 +117,7 @@ def self.search_by_similarity(text, language, team_id, limit) context: context } response = Bot::Alegre.query_sync_with_params(params, "text") - results = response['result'].to_a.sort_by{ |result| result['_score'] } + results = response['result'].to_a.sort_by{ |result| [result['model'] != Bot::Alegre::ELASTICSEARCH_MODEL ? 1 : 0, result['_score']] }.reverse explainer_ids = results.collect{ |result| result.dig('context', 'explainer_id').to_i }.uniq.first(limit) explainer_ids.empty? ? Explainer.none : Explainer.where(team_id: team_id, id: explainer_ids) end