mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-11-29 10:24:20 +01:00
23 lines
656 B
Ruby
23 lines
656 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)
|
||
|
openlab_client.create(project.openlab_attributes)
|
||
|
when /update/
|
||
|
project = Project.find(project_id)
|
||
|
openlab_client.update(project_id, project.openlab_attributes)
|
||
|
when /destroy/
|
||
|
openlab_client.destroy(project_id)
|
||
|
end
|
||
|
end
|
||
|
end
|