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

@@ -1,26 +0,0 @@
require 'zoom_gateway'
class AttachRecordingToZoomMeetingJob < ApplicationJob
queue_as :default
def perform(zoom_meeting, recording_hash, download_token)
download_url = "#{recording_hash['download_url']}?access_token=#{download_token}"
file = URI.open(download_url)
if zoom_meeting.recording.attach(io: file, filename: file_name(zoom_meeting, recording_hash), content_type: 'video/mp4')
# Temorarily disabling notifications
# if zoom_meeting.project.present?
# ProjectsChannel.conference_recording_ready(zoom_meeting.project, zoom_meeting.recording)
# end
gateway = ZoomGateway.new
gateway.delete_recording(zoom_meeting.api_meeting_id, recording_hash['id'])
end
end
private
def file_name(zoom_meeting, recording_hash)
start = recording_hash['recording_start'].to_datetime
prefix = zoom_meeting.project.present? ? "#{zoom_meeting.project.name}_" : ''
"#{prefix}video_conference_date#{start.strftime("%Y-%m-%d")}_Time_#{start.strftime("%T")}.mp4"
end
end

View File

@@ -1,75 +0,0 @@
# frozen_string_literal: true
class MatchAppearanceReleasesJob < ApplicationJob
queue_as :default
def perform(project, attachments)
matching_request = MatchingRequest.create project: project, attachments: attachments
payload = { request_id: matching_request.id, bucket: aws_bucket_name, files: attachments}
response = BrayniacAI::AppearanceReleaseMatching.match_attachments payload
# BrayniacAI::QrMatching.enable_logging
# response = BrayniacAI::QrMatching.create! payload
matches = response[:matches] || []
handle_matches matches, project
matching_request.destroy
end
private
def handle_matches(matches, project)
matches.each do |match|
contract = match[:contracts].blank? ? nil : match[:contracts].first
headshot = match[:headshots].blank? ? nil : match[:headshots].first
identifier = match[:identifier]
next if contract.nil? && headshot.nil?
identified_release = identifier.blank? ? nil : AppearanceRelease.find_by(identifier: identifier)
if identified_release.nil?
create_release project, contract, headshot, identifier
else
update_release identified_release, contract, headshot
end
end
end
def create_release(project, contract, headshot, identifier)
random_contract_no = AppearanceRelease.random_contract_number.to_s
is_incomplete = contract.nil? || headshot.nil?
params = {
project: project,
person_first_name: appearance_first_name(is_incomplete),
person_last_name: random_contract_no
}
params[:person_photo] = headshot unless headshot.nil?
params[:contract] = contract unless contract.nil?
params[:identifier] = identifier unless blank?
return if AppearanceRelease.create(params)
logger.error "Failed to create AppearanceRelease with params : \r\n#{params}"
end
def update_release(release, contract, headshot)
release.contract = contract unless contract.nil?
release.person_photo = headshot unless headshot.nil?
release.save
end
def appearance_first_name(incomplete)
if incomplete
I18n.t('appearance_releases.shared.incomplete_match')
else
I18n.t('appearance_releases.shared.matched_import')
end
end
def aws_bucket_name
ENV.fetch 'AWS_BUCKET'
end
end