diff options
| author | Teddy Wing | 2018-02-07 13:01:01 +0100 | 
|---|---|---|
| committer | Teddy Wing | 2018-02-08 11:29:31 +0100 | 
| commit | f6bc7ad342c19393d364341b3e753154df78a295 (patch) | |
| tree | 76e50573e003e5dd6c936c18de3b117b78b8dbad | |
| parent | 871a088ccffc47e5e09272b3105dabecf10974a6 (diff) | |
| download | chouette-core-f6bc7ad342c19393d364341b3e753154df78a295.tar.bz2 | |
schedule.rb: Add cron job to finalise `ComplianceCheckSet`s
A new recurring job that does exactly the same thing as the import job.
This finalises `ComplianceCheckSet`s.
First we need to abort all unfinished `ComplianceCheckSet`s older than
four hours. Then we finalise the imports by doing the same work in
`Api::V1::Internals::ComplianceCheckSetsController#notify_parent`,
namely calling `#notify_parent` on `ComplianceCheckSet`s (here, only on
the ones that are finished).
Add a couple new Rake tasks for compliance check sets that mirror those
for imports, and do the work required by the cron job.
Refs #4758
| -rw-r--r-- | config/schedule.rb | 5 | ||||
| -rw-r--r-- | lib/tasks/compliance_check_sets.rb | 11 | 
2 files changed, 16 insertions, 0 deletions
| diff --git a/config/schedule.rb b/config/schedule.rb index 08488c255..532707470 100644 --- a/config/schedule.rb +++ b/config/schedule.rb @@ -43,6 +43,11 @@ every 5.minutes do    rake "import:notify_parent"  end +every 5.minutes do +  rake "compliance_check_sets:abort_old" +  rake "compliance_check_sets:notify_parent" +end +  every 1.minute do    command "/bin/echo HeartBeat"  end diff --git a/lib/tasks/compliance_check_sets.rb b/lib/tasks/compliance_check_sets.rb new file mode 100644 index 000000000..c53c7f9ed --- /dev/null +++ b/lib/tasks/compliance_check_sets.rb @@ -0,0 +1,11 @@ +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 | 
