mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-12-11 22:24:21 +01:00
25 lines
785 B
Ruby
25 lines
785 B
Ruby
class OpenlabWorker
|
|
include Sidekiq::Worker
|
|
sidekiq_options queue: 'default', retry: true
|
|
|
|
Logger = Sidekiq.logger.level == Logger::DEBUG ? Sidekiq.logger : nil
|
|
OPENLAB_CLIENT = Openlab::Projects.new
|
|
|
|
def perform(action, project_id)
|
|
logger.debug ["Openlab sync", action, "project ID: #{project_id}"]
|
|
|
|
case action.to_s
|
|
when /create/
|
|
project = Project.find(project_id)
|
|
response = OPENLAB_CLIENT.create(project.openlab_attributes)
|
|
when /update/
|
|
project = Project.find(project_id)
|
|
response = OPENLAB_CLIENT.update(project_id, project.openlab_attributes)
|
|
when /destroy/
|
|
response = OPENLAB_CLIENT.destroy(project_id)
|
|
end
|
|
|
|
logger.debug ["Openlab sync", "RESPONSE ERROR", response.inspect] unless response.success?
|
|
end
|
|
end
|