diff options
| author | Teddy Wing | 2017-08-01 20:47:15 +0200 |
|---|---|---|
| committer | Teddy Wing | 2017-08-01 20:47:15 +0200 |
| commit | 985f22e3d4c7c503c4f830f00692a1219ade9612 (patch) | |
| tree | 5e8eb9d99d1ab9950c5eeceeff80947c51e9e9a0 /app | |
| parent | f189c4331d4f6f1ed10b7545d90a92dc2b7ca9b1 (diff) | |
| download | chouette-core-985f22e3d4c7c503c4f830f00692a1219ade9612.tar.bz2 | |
Import: Make #child_change work
The `#child_change` method should update the current import (the parent)
with a 'failed' or 'successful' status depending on the status of the
child passed in.
If the child has a failure status, the parent import should be updated
to failed. If the import is `#ready?`, that tells us that all children
have called `#child_change` without any problems, and we can update the
parent's status to be successful. THAT PARAGRAPH IS WRONG. We could have
`#ready?` with failed children. NEED TO UPDATE TO SUPPORT THAT.
Add a method that describes the possible "failing" statuses. These are
the ones that will cause 'failed' to be set on the parent.
Refs #3509, #3511
Diffstat (limited to 'app')
| -rw-r--r-- | app/models/import.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/app/models/import.rb b/app/models/import.rb index 46de0d727..c7f6d99df 100644 --- a/app/models/import.rb +++ b/app/models/import.rb @@ -18,6 +18,11 @@ class Import < ActiveRecord::Base end def child_change(child) + if failing_statuses.include?(child.status) + return update(status: 'failed') + end + + return update(status: 'successful') if ready? end def ready? @@ -30,4 +35,8 @@ class Import < ActiveRecord::Base self.token_download = SecureRandom.urlsafe_base64 self.status = Import.status.new end + + def failing_statuses + %i(failed aborted canceled).flat_map { |status| [status, status.to_s] } + end end |
