diff options
| author | Edouard Maffert | 2016-08-01 15:10:28 +0200 | 
|---|---|---|
| committer | Edouard Maffert | 2016-08-01 15:10:28 +0200 | 
| commit | e270eb3a515d897b2157897e83bc5d4cdb670d62 (patch) | |
| tree | 1a39a7e2aa46eac838046916caf8f59008a1bddb /lib/stif/codif_line_synchronization.rb | |
| parent | 4d0bbfcf7aa6cf8cb313954363d925a823756844 (diff) | |
| download | chouette-core-e270eb3a515d897b2157897e83bc5d4cdb670d62.tar.bz2 | |
fix line synchronization
Diffstat (limited to 'lib/stif/codif_line_synchronization.rb')
| -rw-r--r-- | lib/stif/codif_line_synchronization.rb | 10 | 
1 files changed, 7 insertions, 3 deletions
| diff --git a/lib/stif/codif_line_synchronization.rb b/lib/stif/codif_line_synchronization.rb index f14dc6f31..9a8a92bce 100644 --- a/lib/stif/codif_line_synchronization.rb +++ b/lib/stif/codif_line_synchronization.rb @@ -13,14 +13,13 @@ module Stif            # Fetch Codifline operators and lines            client = Codifligne::API.new            operators = client.operators -          # Get last sync date for lines if not first sync -          date = first_sync ? 0 : last_sync.to_date.strftime("%d%m%Y") -          lines = client.lines date: date +          lines = client.lines            operators.map{ |o| create_or_update_company(o) }            lines.map{ |l| create_or_update_line(l) }            delete_deprecated_companies(operators) +          delete_deprecated_lines(lines)            LineReferential.first.line_referential_sync.record_status "OK"          rescue Exception => e @@ -60,6 +59,11 @@ module Stif          Chouette::Company.where.not(objectid: ids).destroy_all        end +      def delete_deprecated_lines(lines) +        ids = lines.map{ |l| l.stif_id }.to_a +        Chouette::Line.where.not(objectid: ids).map { |l| l.deactivated = true ; l.save } +      end +        def save_or_update(params, klass)          params[:line_referential] = LineReferential.first          object = klass.where(objectid: params[:objectid]).first | 
