From cf63f8f32ecaa6f1bccc70a68e4c6d4d8794373b Mon Sep 17 00:00:00 2001 From: Zog Date: Mon, 16 Apr 2018 11:38:31 +0200 Subject: Add a task to check stop points positions --- lib/tasks/checks.rake | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 lib/tasks/checks.rake (limited to 'lib/tasks') diff --git a/lib/tasks/checks.rake b/lib/tasks/checks.rake new file mode 100644 index 000000000..23c638964 --- /dev/null +++ b/lib/tasks/checks.rake @@ -0,0 +1,19 @@ +namespace :check do + desc "Check routes stop_points positions are valid" + task routes_integrity: :environment do + errors = [] + max = Referential.pluck(:name).map(&:size).max + 20 + Referential.find_each do |r| + r.switch do + Chouette::Route.find_each do |route| + positions = route.stop_points.pluck(:position) + if positions.size != positions.uniq.size + lb = "Referential: #{r.id}/#{r.name}" + errors << "#{lb + " "*(max-lb.size)} -> Wrong positions in Route #{route.id} : #{positions.inspect} " + end + end + end + end + puts errors.join("\n") + end +end -- cgit v1.2.3