aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorTeddy Wing2018-02-05 15:49:25 +0100
committerTeddy Wing2018-02-06 10:50:51 +0100
commit4c3e7adbeccfcbc39de845880882893b5b734741 (patch)
tree487e233f19604e744eca338f75f8ea1f1125c7a0 /app
parentf3d6710c7a19f835f17dff762dfe520fcffc6d63 (diff)
downloadchouette-core-4c3e7adbeccfcbc39de845880882893b5b734741.tar.bz2
Import: Add `.abort_old` method
This will abort all imports that don't have a finished status and were created more than four hours ago. We want to add this functionality to the import cron to auto-abort stale imports. Refs #4963
Diffstat (limited to 'app')
-rw-r--r--app/models/import.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/app/models/import.rb b/app/models/import.rb
index 049a65f40..6330bd560 100644
--- a/app/models/import.rb
+++ b/app/models/import.rb
@@ -42,6 +42,11 @@ class Import < ActiveRecord::Base
%w(successful failed warning aborted canceled)
end
+ def self.abort_old
+ where('created_at < ?', 4.hours.ago)
+ .update_all(status: 'aborted')
+ end
+
def notify_parent
parent.child_change
update(notified_parent_at: DateTime.now)