refactor matching job
This commit is contained in:
@@ -9,9 +9,10 @@ class MatchAppearanceReleasesJob < ApplicationJob
|
|||||||
return if filtered_attachments_object[:keys].blank?
|
return if filtered_attachments_object[:keys].blank?
|
||||||
|
|
||||||
matching_request = MatchingRequest.create project: project, attachments: filtered_attachments_object[:signed_ids]
|
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]}
|
payload = { request_id: matching_request.id, bucket: aws_bucket_name, files: filtered_attachments_object[:keys]}
|
||||||
response = BrayniacAI::QrMatching.create! payload
|
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])]
|
key_signed_id_hash = Hash[filtered_attachments_object[:keys].zip(filtered_attachments_object[:signed_ids])]
|
||||||
handle_matches matches, project, key_signed_id_hash
|
handle_matches matches, project, key_signed_id_hash
|
||||||
matching_request.destroy
|
matching_request.destroy
|
||||||
@@ -20,11 +21,10 @@ class MatchAppearanceReleasesJob < ApplicationJob
|
|||||||
private
|
private
|
||||||
|
|
||||||
def handle_matches(matches, project, key_signed_id_hash)
|
def handle_matches(matches, project, key_signed_id_hash)
|
||||||
matches.each do |qr_matching_match|
|
matches.each do |match|
|
||||||
match = qr_matching_match.attributes
|
contract_key = match.contracts.blank? ? nil : match.contracts.first
|
||||||
contract_key = match[:contracts].blank? ? nil : match[:contracts].first
|
headshot_key = match.headshots.blank? ? nil : match.headshots.first
|
||||||
headshot_key = match[:headshots].blank? ? nil : match[:headshots].first
|
identifier = match.identifier
|
||||||
identifier = match[:identifier]
|
|
||||||
|
|
||||||
contract = key_signed_id_hash[contract_key]
|
contract = key_signed_id_hash[contract_key]
|
||||||
headshot = key_signed_id_hash[headshot_key]
|
headshot = key_signed_id_hash[headshot_key]
|
||||||
|
|||||||
Reference in New Issue
Block a user