2012-12-11 10:42:15 +00:00
|
|
|
module AbfWorker
|
2012-12-11 15:25:25 +00:00
|
|
|
class BaseObserver
|
2012-12-13 12:30:37 +00:00
|
|
|
COMPLETED = 0
|
|
|
|
FAILED = 1
|
|
|
|
PENDING = 2
|
|
|
|
STARTED = 3
|
|
|
|
CANCELED = 4
|
2012-12-11 11:47:32 +00:00
|
|
|
|
2012-12-11 15:25:25 +00:00
|
|
|
def self.update_results(subject, options)
|
2012-12-12 12:32:47 +00:00
|
|
|
results = (subject.results || []) + options['results']
|
|
|
|
sort_results_and_save(subject, results)
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.sort_results_and_save(subject, results)
|
2012-12-11 11:47:32 +00:00
|
|
|
subject.results = results.sort_by{ |r| r['file_name'] }
|
|
|
|
subject.save!
|
|
|
|
end
|
|
|
|
|
2012-12-11 10:42:15 +00:00
|
|
|
end
|
|
|
|
end
|