Skip to content

Commit

Permalink
CV2-5779: use same sort for explainer
Browse files Browse the repository at this point in the history
  • Loading branch information
melsawy committed Dec 15, 2024
1 parent b3f5756 commit 21d37bf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/explainer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 21d37bf

Please sign in to comment.