diff options
| author | Xinhui | 2016-09-27 11:34:35 +0200 | 
|---|---|---|
| committer | Xinhui | 2016-09-27 15:18:06 +0200 | 
| commit | 12f506a82ae9099cface5b9507dd8a36bf923508 (patch) | |
| tree | 405cbcea60766fb88f3d324805ce46efff84919c /lib/stif/codif_line_synchronization.rb | |
| parent | 811d6208f4a126b08fc7ae8c4233ce8fca1eb198 (diff) | |
| download | chouette-core-12f506a82ae9099cface5b9507dd8a36bf923508.tar.bz2 | |
Rspec model LineReferentialSync
Diffstat (limited to 'lib/stif/codif_line_synchronization.rb')
| -rw-r--r-- | lib/stif/codif_line_synchronization.rb | 13 | 
1 files changed, 1 insertions, 12 deletions
| diff --git a/lib/stif/codif_line_synchronization.rb b/lib/stif/codif_line_synchronization.rb index 4bbc48946..fee785766 100644 --- a/lib/stif/codif_line_synchronization.rb +++ b/lib/stif/codif_line_synchronization.rb @@ -1,15 +1,8 @@  module Stif    module CodifLineSynchronization      class << self -      # Don't check last synchronizations if force_sync -      def synchronize force_sync = false -        # Check last synchronization and synchronization interval -        date = DateTime.now.to_date - LineReferential.first.sync_interval.days -        last_sync = LineReferential.first.line_referential_sync.line_sync_operations.where(status: :ok).last.try(:created_at) -        return if last_sync.present? && last_sync.to_date > date && !force_sync - +      def synchronize          start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC, :second) -        # TODO Check exceptions and status messages          begin            # Fetch Codifline data            client = Codifligne::API.new @@ -60,13 +53,9 @@ module Stif            total_codifligne_elements = operators.count + lines.count + networks.count + groups_of_lines.count            total_deleted = deleted_op + deleted_li + deleted_ne + deleted_gr            total_time = elapsed_time_since start_time - -          LineReferential.first.line_referential_sync.record_status :ok, I18n.t('synchronization.codifligne.message.success', time: total_time, imported: total_codifligne_elements, deleted: total_deleted)          rescue Exception => e            total_time = elapsed_time_since start_time -            Rails.logger.error "Codifligne:sync - Error: #{e}, ended after #{total_time} seconds" -          LineReferential.first.line_referential_sync.record_status :ko, I18n.t('synchronization.codifligne.message.failure', time: total_time)          end        end | 
