refactor matching job

This commit is contained in:
bilal
2020-06-11 10:31:14 +02:00
parent 1d1df4a1da
commit dc7f50b932

View File

@@ -9,9 +9,10 @@ class MatchAppearanceReleasesJob < ApplicationJob
return if filtered_attachments_object[:keys].blank?
matching_request = MatchingRequest.create project: project, attachments: filtered_attachments_object[:signed_ids]
payload = { request_id: matching_request.id, bucket: aws_bucket_name, files: filtered_attachments_object[:keys]}
response = BrayniacAI::QrMatching.create! payload
matches = response.attributes[:matches] || []
matches = response.matches || []
key_signed_id_hash = Hash[filtered_attachments_object[:keys].zip(filtered_attachments_object[:signed_ids])]
handle_matches matches, project, key_signed_id_hash
matching_request.destroy
@@ -20,11 +21,10 @@ class MatchAppearanceReleasesJob < ApplicationJob
private
def handle_matches(matches, project, key_signed_id_hash)
matches.each do |qr_matching_match|
match = qr_matching_match.attributes
contract_key = match[:contracts].blank? ? nil : match[:contracts].first
headshot_key = match[:headshots].blank? ? nil : match[:headshots].first
identifier = match[:identifier]
matches.each do |match|
contract_key = match.contracts.blank? ? nil : match.contracts.first
headshot_key = match.headshots.blank? ? nil : match.headshots.first
identifier = match.identifier
contract = key_signed_id_hash[contract_key]
headshot = key_signed_id_hash[headshot_key]