aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Gemfile.lock2
-rw-r--r--lib/stif/reflex_synchronization.rb8
-rw-r--r--spec/tasks/reflex_rake_spec.rb4
3 files changed, 10 insertions, 4 deletions
diff --git a/Gemfile.lock b/Gemfile.lock
index f3caa6c16..adf7c7999 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -14,7 +14,7 @@ GIT
GIT
remote: git@github.com:AF83/stif-reflex-api.git
- revision: 5b24a3b20a2dd19475eafb1d3db50b9379d0109a
+ revision: 2c01010dce3a6cb39339995c373faf89ae00f3f3
branch: sax_refactoring
specs:
reflex (0.0.1)
diff --git a/lib/stif/reflex_synchronization.rb b/lib/stif/reflex_synchronization.rb
index dbd733e99..32fcbc531 100644
--- a/lib/stif/reflex_synchronization.rb
+++ b/lib/stif/reflex_synchronization.rb
@@ -28,6 +28,7 @@ module Stif
start = Time.now
stop_areas.each do |entry|
+ next unless is_valid_type_of_place_ref?(method, entry)
processed << entry['id']
self.create_or_update_stop_area entry
end
@@ -42,10 +43,15 @@ module Stif
end
{
imported: Chouette::StopArea.where(deleted_at: nil).count - initial_count,
- deleted: self.set_deleted_stop_area(processed.uniq)
+ deleted: self.set_deleted_stop_area(processed.uniq).size
}
end
+ def is_valid_type_of_place_ref? method, entry
+ return true if method == 'getOR' && ['ZDL', 'ZDE'].include?(entry["TypeOfPlaceRef"])
+ return true if method == 'getOP' && ['LDA', 'ZDE'].include?(entry["TypeOfPlaceRef"])
+ end
+
def set_deleted_stop_area processed
start = Time.now
deleted = Chouette::StopArea.where(deleted_at: nil).pluck(:objectid).uniq - processed
diff --git a/spec/tasks/reflex_rake_spec.rb b/spec/tasks/reflex_rake_spec.rb
index 7a27b49fc..2c2b293a2 100644
--- a/spec/tasks/reflex_rake_spec.rb
+++ b/spec/tasks/reflex_rake_spec.rb
@@ -14,7 +14,7 @@ describe 'reflex:sync' do
end
it 'should create stopArea on successfull request' do
- expect(Chouette::StopArea.count).to eq 6
+ expect(Chouette::StopArea.count).to eq 4
expect(Chouette::AccessPoint.count).to eq 2
end
@@ -44,7 +44,7 @@ describe 'reflex:sync' do
end
it 'should not create duplicate stop_area' do
- expect(Chouette::StopArea.count).to eq 6
+ expect(Chouette::StopArea.count).to eq 4
expect(Chouette::AccessPoint.count).to eq 2
end