aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLuc Donnet2018-03-16 13:46:54 +0100
committerLuc Donnet2018-03-16 13:46:54 +0100
commit193b85cc7882762d99f412b796c67f9c350172cd (patch)
treeb8fd3ea3a46b16a24936ec83ca9dd6eb12462275 /lib
parentf45dbdcb2869bf98e4b3625acbd10e3835a07ea4 (diff)
downloadchouette-core-193b85cc7882762d99f412b796c67f9c350172cd.tar.bz2
Fix stop_area state for filter and display. Update reflex sync to use confirmed_at. Refs #6141
Diffstat (limited to 'lib')
-rw-r--r--lib/stif/reflex_synchronization.rb32
1 files changed, 17 insertions, 15 deletions
diff --git a/lib/stif/reflex_synchronization.rb b/lib/stif/reflex_synchronization.rb
index 7570e4c49..4eb5bb541 100644
--- a/lib/stif/reflex_synchronization.rb
+++ b/lib/stif/reflex_synchronization.rb
@@ -51,7 +51,7 @@ module Stif
stop_areas = results[:Quay] | results[:StopPlace]
time = Benchmark.measure do
- stop_areas.each do |entry|
+ stop_areas.in_batches.each do |entry|
next unless is_valid_type_of_place_ref?(method, entry)
entry['TypeOfPlaceRef'] = self.stop_area_area_type entry, method
self.create_or_update_stop_area entry
@@ -151,23 +151,25 @@ module Stif
def create_or_update_stop_area entry
stop = Chouette::StopArea.find_or_create_by(objectid: entry['id'], stop_area_referential: self.defaut_referential )
- stop.kind = :commercial
- stop.deleted_at = nil
{
- :comment => 'Description',
- :name => 'Name',
- :area_type => 'TypeOfPlaceRef',
- :object_version => 'version',
- :zip_code => 'PostalRegion',
- :city_name => 'Town',
- :stif_type => 'OBJECT_STATUS'
+ kind: :commercial,
+ deleted_at: nil,
+ comment: 'Description',
+ :name 'Name',
+ :area_type 'TypeOfPlaceRef',
+ :object_version 'version',
+ :zip_code 'PostalRegion',
+ :city_name 'Town',
+ :stif_type 'OBJECT_STATUS',
+ longitude: (entry['gml:pos'][:lng] && entry['gml:pos'][:lng]) ? entry['gml:pos'][:lng] : nil,
+ latitude: (entry['gml:pos'][:lat] && entry['gml:pos'][:lat]) ? entry['gml:pos'][:lat] : nil
}.each do |k, v| stop[k] = entry[v] end
- # TODO: use stop.update_attributes instead of the above
- if entry['gml:pos']
- stop['longitude'] = entry['gml:pos'][:lng]
- stop['latitude'] = entry['gml:pos'][:lat]
- end
+ # if entry['gml:pos']
+ # stop['longitude'] = entry['gml:pos'][:lng]
+ # stop['latitude'] = entry['gml:pos'][:lat]
+ # end
+ stop.confirmed_at = Time.now if stop.new_record?
if stop.changed?
stop.created_at = entry[:created]