Skip to content

Commit

Permalink
update function based on it being a hash that's actually being passed…
Browse files Browse the repository at this point in the history
… around
  • Loading branch information
DGaffney committed Jan 30, 2024
1 parent bb42266 commit 14f8b53
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions app/models/concerns/alegre_v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,11 @@ def parse_similarity_results(project_media, field, results, relationship_type)
}.reject{ |k,_| k == project_media.id }]
end

def safe_get_sync(project_media, field, threshold)
response = get_sync(project_media, field, threshold)
def safe_get_sync(project_media, field, params={})
response = get_sync(project_media, field, params)
retries = 0
while (response == nil or response["result"] == nil) and retries < 3
response = get_sync(project_media, field, threshold)
response = get_sync(project_media, field, params)
retries += 1
end
response
Expand Down
2 changes: 1 addition & 1 deletion test/models/bot/alegre_v2_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def teardown
pm1 = create_project_media team: @team, media: create_uploaded_audio
response = {}
WebMock.stub_request(:post, "#{CheckConfig.get('alegre_host')}/similarity/sync/audio").with(body: {:doc_id=>Bot::Alegre.item_doc_id(pm1), :context=>{:team_id=>pm1.team_id, :project_media_id=>pm1.id, :has_custom_id=>true}, :url=>Bot::Alegre.media_file_url(pm1)}).to_return(body: response.to_json)
assert_equal Bot::Alegre.safe_get_sync(pm1, "audio", 0.9), {}
assert_equal Bot::Alegre.safe_get_sync(pm1, "audio", {}), {}
end

test "should run delete request" do
Expand Down

0 comments on commit 14f8b53

Please sign in to comment.