beta build
This commit is contained in:
@@ -13,7 +13,7 @@ module AutomationService
|
||||
if member.present?
|
||||
member.save
|
||||
else
|
||||
Member.find_by(pb_entity_key: vw_mb_member[:pb_entity_key]).destroy
|
||||
Member.find_by(pb_entity_key: @pb_entity_key).destroy
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
require 'rake'
|
||||
|
||||
class BetaAutomationSimulationService
|
||||
def initialize()
|
||||
end
|
||||
|
||||
def call
|
||||
Rails::Command.invoke('employer_automation:employer_initialize_test')
|
||||
# Rails::Command.invoke('employer_automation:employer_initialize_test')
|
||||
|
||||
Rails.application.load_tasks
|
||||
Rake::Task['employer_automation:employer_initialize_test'].invoke
|
||||
end
|
||||
end
|
||||
Executable
+33
@@ -0,0 +1,33 @@
|
||||
class ImageProcessorService
|
||||
ALLOWED_LOGO_TYPES = ['Network', 'Employer'].freeze
|
||||
|
||||
def initialize(image_path, logo_type, new_filename = nil)
|
||||
@image_path = image_path
|
||||
@logo_type = logo_type.capitalize
|
||||
@new_filename = new_filename
|
||||
|
||||
unless ALLOWED_LOGO_TYPES.include?(@logo_type)
|
||||
raise ArgumentError, "Invalid logo type: #{@logo_type}. Must be one of: #{ALLOWED_LOGO_TYPES.join(', ')}"
|
||||
end
|
||||
end
|
||||
|
||||
def call
|
||||
|
||||
if @new_filename
|
||||
filename = @new_filename
|
||||
else
|
||||
filename = File.basename(@image_path)
|
||||
end
|
||||
|
||||
binary_data = File.binread(@image_path)
|
||||
# binary_data = File.open(@image_path, 'rb').read
|
||||
meme_type = Marcel::MimeType.for Pathname.new(@image_path)
|
||||
|
||||
logo_model = "IdCard::#{@logo_type}Logo".constantize
|
||||
|
||||
logo_model.find_or_create_by(filename: filename) do |logo|
|
||||
logo.image_data = binary_data
|
||||
logo.content_type = meme_type
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user