Skip to content

Commit

Permalink
rename function and revert request
Browse files Browse the repository at this point in the history
  • Loading branch information
DGaffney committed Aug 19, 2024
1 parent 89d6b8b commit 6e6e68f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/models/concerns/alegre_v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/article.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions app/models/explainer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 6e6e68f

Please sign in to comment.