aboutsummaryrefslogtreecommitdiffstats
path: root/lib/tasks
diff options
context:
space:
mode:
authorZog2018-04-16 11:38:31 +0200
committerZog2018-04-16 11:38:31 +0200
commitcf63f8f32ecaa6f1bccc70a68e4c6d4d8794373b (patch)
treee04bee236805fa6dc1d06df1200deb430ced9896 /lib/tasks
parent69feaded19e5dec406424b1ee42bf3e1d7936ad5 (diff)
downloadchouette-core-cf63f8f32ecaa6f1bccc70a68e4c6d4d8794373b.tar.bz2
Add a task to check stop points positions
Diffstat (limited to 'lib/tasks')
-rw-r--r--lib/tasks/checks.rake19
1 files changed, 19 insertions, 0 deletions
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