Skip to content

Commit

Permalink
alias and rename per caio review
Browse files Browse the repository at this point in the history
  • Loading branch information
DGaffney committed Sep 5, 2024
1 parent 72c0ce0 commit 5a57f5c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/lib/smooch_nlu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def update_keywords(language, keywords, keyword, operation, doc_id, context)
}
if operation == 'add' && !keywords.include?(keyword)
keywords << keyword
Bot::Alegre.get_sync_with_params(common_alegre_params.merge({ text: keyword, models: ALEGRE_MODELS_AND_THRESHOLDS.keys }), "text")
Bot::Alegre.index_sync_with_params(common_alegre_params.merge({ text: keyword, models: ALEGRE_MODELS_AND_THRESHOLDS.keys }), "text")
elsif operation == 'remove'
keywords -= [keyword]
Bot::Alegre.request_delete_from_raw(common_alegre_params.merge({ quiet: true }), "text")
Expand Down Expand Up @@ -87,7 +87,7 @@ def self.alegre_matches_from_message(message, language, context, alegre_result_k
language: language,
}.merge(context)
}
response = Bot::Alegre.get_sync_with_params(params, "text")
response = Bot::Alegre.query_sync_with_params(params, "text")

# One approach would be to take the option that has the most matches
# Unfortunately this approach is influenced by the number of keywords per option
Expand Down
5 changes: 3 additions & 2 deletions app/models/concerns/alegre_v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,11 @@ def index_async_with_params(params, type, suppress_search_response=true)
request("post", async_path_for_type(type), params.merge(suppress_search_response: suppress_search_response))
end

def get_sync_with_params(params, type)
def query_sync_with_params(params, type)
request("post", sync_path_for_type(type), params)
end

def get_async_with_params(params, type)
def query_async_with_params(params, type)
request("post", async_path_for_type(type), params)
end

Expand Down Expand Up @@ -576,4 +576,5 @@ def restrict_contexts(project_media, project_media_id_scores)
}]
end
end
alias :index_sync_with_params, :query_sync_with_params
end
2 changes: 1 addition & 1 deletion app/models/explainer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def self.search_by_similarity(text, language, team_id)
language: language
}
}
response = Bot::Alegre.get_async_with_params(params, "text")
response = Bot::Alegre.query_async_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)
Expand Down

0 comments on commit 5a57f5c

Please sign in to comment.