Task me sync

This commit is contained in:
Senad Uka
2020-06-03 07:24:01 +02:00
parent e3d4d22a34
commit 88836e937e
76 changed files with 847 additions and 497 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

View File

@@ -23,10 +23,6 @@ class ZoomGateway
"#{self.USER_TYPE_NAME}-directme-host"
end
def enable_recordings?
ENV['ZOOM_ENABLE_RECORDINGS'] == '1'
end
def apply_limits?
self.USER_TYPE_NAME == 'pro'
end
@@ -37,14 +33,12 @@ class ZoomGateway
end
def create_meeting(host_id, **kwargs)
recording_type = self.class.enable_recordings? ? 'cloud' : 'none'
meeting = @client.meeting_create({ user_id: host_id,
topic: kwargs[:topic],
type: 1, # Instant meeting
settings: {
host_video: true,
participant_video: true,
auto_recording: recording_type,
participant_video: true
} })
meeting["id"]
end
@@ -84,10 +78,6 @@ class ZoomGateway
@client.user_delete(id: host_id)
end
def delete_recording(meeting_id, recording_id)
@client.recording_delete(meeting_id: meeting_id, recording_id: recording_id)
end
private
def parse_zoom_error(error)