fix MR comments

This commit is contained in:
bilal
2020-06-16 08:51:54 +02:00
parent 3650d6022c
commit 2238338710
5 changed files with 5 additions and 77 deletions

View File

@@ -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"

View File

@@ -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