diff options
| author | cedricnjanga | 2018-05-28 05:53:05 -0700 | 
|---|---|---|
| committer | Johan Van Ryseghem | 2018-05-28 16:20:55 +0200 | 
| commit | 9df209e05344c30cfa126522adaffa4c7ad463bd (patch) | |
| tree | 3b762cc48d8c9b5de67038fb8b55760b5954e58e | |
| parent | 3f7c4b11e27fba2abba6e5bfa676f41b886896e5 (diff) | |
| download | chouette-core-9df209e05344c30cfa126522adaffa4c7ad463bd.tar.bz2 | |
Refs #6962 Fix wrong syntac in schedule file & remove unnecessary rake files
| -rw-r--r-- | config/schedule.rb | 14 | ||||
| -rw-r--r-- | lib/cron.rb | 24 | ||||
| -rw-r--r-- | lib/tasks/codifligne.rake | 8 | ||||
| -rw-r--r-- | lib/tasks/compliance_check_sets.rb | 11 | ||||
| -rw-r--r-- | lib/tasks/imports.rake | 10 | ||||
| -rw-r--r-- | lib/tasks/organisations.rake | 6 | ||||
| -rw-r--r-- | lib/tasks/reflex.rake | 8 | ||||
| -rw-r--r-- | lib/tasks/users.rake | 6 | 
8 files changed, 27 insertions, 60 deletions
| diff --git a/config/schedule.rb b/config/schedule.rb index e5ab2556d..9642fa3a4 100644 --- a/config/schedule.rb +++ b/config/schedule.rb @@ -28,23 +28,19 @@ set :NEW_RELIC_LOG, 'stdout'  set :job_template, "/bin/bash -c ':job'"  every :hour do -  Cron.sync_organizations -  Cron.sync_users +  runner "Cron.every_hour"  end  every :day, :at => '3:00am' do -  Cron.sync_reflex -end -every :day, :at => '4:00 am' do -  Cron.sync_codifligne +  runner "Cron.every_day_at_3AM"  end -every 5.minutes do -  Cron.check_import_operations +every :day, :at => '4:00 am' do + runner "Cron.every_day_at_4AM"  end  every 5.minutes do -  Cron.check_ccset_operations +  runner "Cron.every_5_minutes"  end  every 1.minute do diff --git a/lib/cron.rb b/lib/cron.rb index 7e2ca4cdf..fe010ffd9 100644 --- a/lib/cron.rb +++ b/lib/cron.rb @@ -1,6 +1,26 @@  module Cron    class << self +    def every_day_at_3AM +      sync_reflex +    end + +    def every_day_at_4AM +      sync_codifligne +    end + +    def every_hour +      sync_organizations +      sync_users +    end + +    def every_5_minutes +      check_import_operations +      check_ccset_operations +    end + +    private +      def sync_organizations        begin          Organisation.portail_sync @@ -37,7 +57,7 @@ module Cron        end      end -    def check_import_operations +    def check_ccset_operations        begin          ParentNotifier.new(ComplianceCheckSet).notify_when_finished          ComplianceCheckSet.abort_old @@ -46,7 +66,7 @@ module Cron        end      end -    def check_ccset_operations +    def check_import_operations        begin          ParentNotifier.new(Import::Base).notify_when_finished          Import::Netex.abort_old diff --git a/lib/tasks/codifligne.rake b/lib/tasks/codifligne.rake deleted file mode 100644 index dd5e99370..000000000 --- a/lib/tasks/codifligne.rake +++ /dev/null @@ -1,8 +0,0 @@ -namespace :codifligne do -  desc "Sync lines, companies, networks, and group of lines from codifligne" -  task sync: :environment  do -    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? -  end -end diff --git a/lib/tasks/compliance_check_sets.rb b/lib/tasks/compliance_check_sets.rb deleted file mode 100644 index c53c7f9ed..000000000 --- a/lib/tasks/compliance_check_sets.rb +++ /dev/null @@ -1,11 +0,0 @@ -namespace :compliance_check_sets do -  desc "Notify parent check sets when children finish" -  task notify_parent: :environment do -    ParentNotifier.new(ComplianceCheckSet).notify_when_finished -  end - -  desc "Mark old unfinished check sets as 'aborted'" -  task abort_old: :environment do -    ComplianceCheckSet.abort_old -  end -end diff --git a/lib/tasks/imports.rake b/lib/tasks/imports.rake index d393ab156..258c37bbd 100644 --- a/lib/tasks/imports.rake +++ b/lib/tasks/imports.rake @@ -2,16 +2,6 @@ require 'csv'  require 'tasks/helpers/simple_interfaces'  namespace :import do -  desc "Notify parent imports when children finish" -    task notify_parent: :environment do -    ParentNotifier.new(Import::Base).notify_when_finished -  end - -  desc "Mark old unfinished Netex imports as 'aborted'" -  task netex_abort_old: :environment do -    Import::Netex.abort_old -  end -    desc "import the given file with the corresponding importer"    task :import, [:configuration_name, :filepath, :referential_id, :logs_output_dir] => :environment do |t, args|      args.with_defaults(logs_output_dir: "./log/importers/") diff --git a/lib/tasks/organisations.rake b/lib/tasks/organisations.rake deleted file mode 100644 index 1b21d7119..000000000 --- a/lib/tasks/organisations.rake +++ /dev/null @@ -1,6 +0,0 @@ -namespace :organisations do -  desc "Sync organisations from stif portail" -  task sync: :environment  do -    Organisation.portail_sync -  end -end diff --git a/lib/tasks/reflex.rake b/lib/tasks/reflex.rake deleted file mode 100644 index 67496cee0..000000000 --- a/lib/tasks/reflex.rake +++ /dev/null @@ -1,8 +0,0 @@ -namespace :reflex do -  desc "Sync data from Reflex api" -  task sync: :environment  do -    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? -  end -end diff --git a/lib/tasks/users.rake b/lib/tasks/users.rake deleted file mode 100644 index c045639c1..000000000 --- a/lib/tasks/users.rake +++ /dev/null @@ -1,6 +0,0 @@ -namespace :users do -  desc "Sync users from stif portail" -  task sync: :environment  do -    User.portail_sync -  end -end | 
