2019-01-25 17:50:08 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rufus-scheduler'
|
|
|
|
|
|
|
|
scheduler = Rufus::Scheduler.singleton
|
|
|
|
|
2021-03-03 00:26:44 +08:00
|
|
|
if ENV['ENABLE_TEMPLATES_SYNC']
|
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
|
|
|
|
|
|
|
if Rails.application.secrets.system_notifications_uri.present? &&
|
2021-03-03 00:26:44 +08:00
|
|
|
Rails.application.secrets.system_notifications_channel.present?
|
2019-02-12 23:07:20 +08:00
|
|
|
|
|
|
|
# System notifications periodic task
|
2021-03-03 00:26:44 +08:00
|
|
|
scheduler.every '1h' do
|
2019-02-12 23:07:20 +08:00
|
|
|
Rails.logger.info('System Notifications syncing')
|
|
|
|
Rails.logger.info(Process.pid)
|
|
|
|
result = Notifications::SyncSystemNotificationsService.call
|
|
|
|
if result.errors.any?
|
|
|
|
Rails.logger.info('System Notifications sync error: ')
|
|
|
|
Rails.logger.info(result.errors.to_s)
|
|
|
|
else
|
|
|
|
Rails.logger.info('System Notifications sync done')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2022-08-29 15:52:54 +08:00
|
|
|
|
|
|
|
if LabelPrinter.fluics.any?
|
|
|
|
scheduler.every '24h' do
|
|
|
|
LabelPrinters::Fluics::SyncService.new.sync_templates!
|
|
|
|
end
|
|
|
|
end
|