2019-01-25 17:50:08 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rufus-scheduler'
|
|
|
|
|
|
|
|
scheduler = Rufus::Scheduler.singleton
|
|
|
|
|
2022-11-07 18:55:01 +08:00
|
|
|
if ENV['ENABLE_TEMPLATES_SYNC'] == 'true'
|
2019-01-25 17:50:08 +08:00
|
|
|
# Templates sync periodic task
|
2021-03-03 00:26:44 +08:00
|
|
|
scheduler.every '12h' do
|
2019-01-25 17:50:08 +08:00
|
|
|
Rails.logger.info('Templates, syncing all template projects')
|
2019-02-13 22:17:33 +08:00
|
|
|
updated, total = TemplatesService.new.update_all_templates
|
2019-01-25 17:50:08 +08:00
|
|
|
Rails.logger.info(
|
|
|
|
"Templates, total number of updated projects: #{updated} out of #{total}}"
|
|
|
|
)
|
|
|
|
Rails.logger.flush
|
|
|
|
end
|
|
|
|
end
|
2019-02-12 23:07:20 +08:00
|
|
|
|
2022-11-07 18:55:01 +08:00
|
|
|
if ENV['ENABLE_FLUICS_SYNC'] == 'true'
|
2022-08-29 15:52:54 +08:00
|
|
|
scheduler.every '24h' do
|
2022-11-07 18:55:01 +08:00
|
|
|
LabelPrinters::Fluics::SyncService.new.sync_templates! if LabelPrinter.fluics.any?
|
2022-08-29 15:52:54 +08:00
|
|
|
end
|
|
|
|
end
|