fix MR comments
This commit is contained in:
@@ -22,8 +22,8 @@ class MatchAppearanceReleasesJob < ApplicationJob
|
||||
|
||||
def handle_matches(matches, project, key_signed_id_hash)
|
||||
matches.each do |match|
|
||||
contract_key = match.contracts.blank? ? nil : match.contracts.first
|
||||
headshot_key = match.headshots.blank? ? nil : match.headshots.first
|
||||
contract_key = Array.wrap(match.contracts).first
|
||||
headshot_key = Array.wrap(match.headshots).first
|
||||
identifier = match.identifier
|
||||
|
||||
contract = key_signed_id_hash[contract_key]
|
||||
|
||||
@@ -56,7 +56,7 @@ class Account < ApplicationRecord
|
||||
Broadcast.where(project: projects),
|
||||
ZoomMeeting.where(project: projects),
|
||||
MedicalRelease.where(project: projects),
|
||||
# MatchingRequest.where(project: projects),
|
||||
MatchingRequest.where(project: projects),
|
||||
self
|
||||
])).sum(:byte_size).to_f
|
||||
end
|
||||
|
||||
@@ -3,7 +3,6 @@ require_relative "./brayniac_ai/aws_request_signing"
|
||||
require_relative "./brayniac_ai/aws_signed_connection"
|
||||
|
||||
require_relative "./brayniac_ai/base"
|
||||
require_relative "./brayniac_ai/appearance_release_matching"
|
||||
require_relative "./brayniac_ai/audio_recognition"
|
||||
require_relative "./brayniac_ai/collection"
|
||||
require_relative "./brayniac_ai/document_analysis"
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module BrayniacAI
|
||||
class AppearanceReleaseMatching
|
||||
class << self
|
||||
def match_attachments(request_data)
|
||||
# TODO: Send request with request_data and receive real response
|
||||
mock_response request_data
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def mock_response(request_data)
|
||||
attachments = request_data[:files]
|
||||
pdfs = []
|
||||
images = []
|
||||
matches = []
|
||||
|
||||
# Use first file for the error entry
|
||||
first_attachment = attachments.shift
|
||||
|
||||
if first_attachment.present?
|
||||
matches << {
|
||||
headshots: [],
|
||||
contracts: [],
|
||||
unknowns: [first_attachment],
|
||||
identifier: ''
|
||||
}
|
||||
end
|
||||
|
||||
attachments.each do |attachment|
|
||||
blob = ActiveStorage::Blob.find_signed attachment
|
||||
next if blob.nil?
|
||||
|
||||
if blob.image?
|
||||
images << attachment
|
||||
else
|
||||
pdfs << attachment
|
||||
end
|
||||
end
|
||||
|
||||
# Create pairs of matches and single headshot/contract after pairs are exhausted
|
||||
more_pdfs = pdfs.length > images.length
|
||||
pairs = more_pdfs ? pdfs.zip(images) : images.zip(pdfs)
|
||||
pairs.each do |pair_element1, pair_element2|
|
||||
if more_pdfs
|
||||
pdf = pair_element1
|
||||
image = pair_element2
|
||||
else
|
||||
pdf = pair_element2
|
||||
image = pair_element1
|
||||
end
|
||||
headshots = image.present? ? [image] : []
|
||||
contracts = pdf.present? ? [pdf] : []
|
||||
|
||||
matches << {
|
||||
headshots: headshots,
|
||||
contracts: contracts,
|
||||
unknowns: [],
|
||||
identifier: ''
|
||||
}
|
||||
end
|
||||
|
||||
{
|
||||
request_id: request_data[:request_id],
|
||||
matches: matches
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -80,8 +80,8 @@ describe MatchAppearanceReleasesJob do
|
||||
MatchAppearanceReleasesJob.perform_now project, signed_ids
|
||||
|
||||
expect(AppearanceRelease.last.identifier).to eq mock_match.identifier
|
||||
expect(AppearanceRelease.last.person_photo.attached?).to eq true
|
||||
expect(AppearanceRelease.last.contract.attached?).to eq false
|
||||
expect(AppearanceRelease.last.person_photo).to be_attached
|
||||
expect(AppearanceRelease.last.contract).not_to be_attached
|
||||
end
|
||||
|
||||
it "creates new incomplete appearance release if BrayniacAI returns single contract match" do
|
||||
|
||||
Reference in New Issue
Block a user