diff options
| author | Xinhui | 2016-09-29 16:17:13 +0200 |
|---|---|---|
| committer | Xinhui | 2016-09-29 16:17:13 +0200 |
| commit | a1fffa57564825303671c20e596f4fc944fbdd12 (patch) | |
| tree | efbfe652a11c48d4818a26b3686ca2f355e612d7 /app/workers | |
| parent | cecd26452ce1cb2486d926421c1ae6360c973d1b (diff) | |
| download | chouette-core-a1fffa57564825303671c20e596f4fc944fbdd12.tar.bz2 | |
Refactoring StopAreaReferentialSync
Refs #1710
Diffstat (limited to 'app/workers')
| -rw-r--r-- | app/workers/stop_area_referential_sync_worker.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/app/workers/stop_area_referential_sync_worker.rb b/app/workers/stop_area_referential_sync_worker.rb new file mode 100644 index 000000000..662652831 --- /dev/null +++ b/app/workers/stop_area_referential_sync_worker.rb @@ -0,0 +1,23 @@ +class StopAreaReferentialSyncWorker + include Sidekiq::Worker + sidekiq_options :retry => false + + def process_time + Process.clock_gettime(Process::CLOCK_MONOTONIC, :second) + end + + def perform(stop_area_ref_sync_id) + start_time = process_time + stop_ref_sync = StopAreaReferentialSync.find stop_area_ref_sync_id + stop_ref_sync.run + begin + info = Stif::ReflexSynchronization.synchronize + stop_ref_sync.successful info.merge({processing_time: process_time - start_time}) + rescue Exception => e + stop_ref_sync.failed({ + error: e.message, + processing_time: process_time - start_time + }) + end + end +end |
