aboutsummaryrefslogtreecommitdiffstats
path: root/lib/cron.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/cron.rb')
-rw-r--r--lib/cron.rb50
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/cron.rb b/lib/cron.rb
new file mode 100644
index 000000000..0b94c2209
--- /dev/null
+++ b/lib/cron.rb
@@ -0,0 +1,50 @@
+module Cron
+ class << self
+
+ def sync_organizations
+ Organisation.portail_sync
+ end
+
+ def sync_users
+ User.portail_sync
+ end
+
+ def sync_reflex
+ begin
+ sync = StopAreaReferential.find_by(name: 'Reflex').stop_area_referential_syncs.build
+ raise "reflex:sync aborted - There is already an synchronisation in progress" unless sync.valid?
+ sync.save if sync.valid?
+ rescue => e
+ Rails.logger.warn(e.message)
+ end
+ end
+
+ def sync_codifligne
+ begin
+ sync = LineReferential.find_by(name: 'CodifLigne').line_referential_syncs.build
+ raise "Codifligne:sync aborted - There is already an synchronisation in progress" unless sync.valid?
+ sync.save if sync.valid?
+ rescue => e
+ Rails.logger.warn(e.message)
+ end
+ end
+
+ def check_import_operations
+ begin
+ ParentNotifier.new(ComplianceCheckSet).notify_when_finished
+ ComplianceCheckSet.abort_old
+ rescue => e
+ Rails.logger.error(e.inspect)
+ end
+ end
+
+ def check_ccset_operations
+ begin
+ ParentNotifier.new(Import::Base).notify_when_finished
+ Import::Netex.abort_old
+ rescue => e
+ Rails.logger.error(e.inspect)
+ end
+ end
+ end
+end \ No newline at end of file