Skip to content

Commit

Permalink
refactors from PR
Browse files Browse the repository at this point in the history
  • Loading branch information
DGaffney committed Jan 30, 2024
1 parent 14f8b53 commit 1900350
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/models/concerns/alegre_v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def parse_similarity_results(project_media, field, results, relationship_type)
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
while (response.nil? || response["result"].nil?) && retries < 3
response = get_sync(project_media, field, params)
retries += 1
end
Expand Down
5 changes: 2 additions & 3 deletions test/models/bot/alegre_v2_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,8 @@ def teardown

test "should safe_get_sync" do
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", {}), {}
WebMock.stub_request(:post, "#{CheckConfig.get('alegre_host')}/similarity/sync/audio").to_return(body: '{}')
assert_equal {}, Bot::Alegre.safe_get_sync(pm1, "audio", {})
end

test "should run delete request" do
Expand Down

0 comments on commit 1900350

Please sign in to comment.