~ihabunek/triglav

845f109f3e878cfa7287941e4f40e6b4b0665e6a — Ivan Habunek 11 months ago 89e30c9
Redo validation when new data is imported
M lib/mix/tasks/triglav/validate_routes.ex => lib/mix/tasks/triglav/validate_routes.ex +4 -0
@@ 14,6 14,10 @@ defmodule Mix.Tasks.Triglav.ValidateRoutes do
    validate()
  end

  #
  # TODO: Make validation fail gracefully if osm or zet data is not loaded.
  #

  def validate() do
    multi = Multi.new() |> Multi.delete_all(:delete, Error)


M lib/triglav/import/osm.ex => lib/triglav/import/osm.ex +3 -0
@@ 6,6 6,7 @@ defmodule Triglav.Import.Osm do
  https://download.geofabrik.de/europe/croatia.html
  """

  alias Mix.Tasks.Triglav.ValidateRoutes
  alias Triglav.Repo

  def run(force \\ false) do


@@ 75,6 76,8 @@ defmodule Triglav.Import.Osm do
      File.rm("croatia-latest.osm.pbf")
      File.rm("croatia-latest.osm.pbf.md5")

      ValidateRoutes.validate()

      IO.puts("Done.")
    else
      IO.puts("You already have the latest OSM data. Use --force option to import anyway.")

A lib/triglav/import/osm_osmium.ex => lib/triglav/import/osm_osmium.ex +0 -0
M lib/triglav/import/zet.ex => lib/triglav/import/zet.ex +3 -0
@@ 6,6 6,7 @@ defmodule Triglav.Import.Zet do
  https://download.geofabrik.de/europe/croatia.html
  """

  alias Mix.Tasks.Triglav.ValidateRoutes
  alias Triglav.Repo
  alias Triglav.Schemas.Zet.FeedInfo



@@ 39,6 40,8 @@ defmodule Triglav.Import.Zet do
      run_sql("priv/gtfs/transform.sql")

      File.rm_rf!(temp_dir)

      ValidateRoutes.validate()
    else
      IO.puts("You already have the latest data. Use :force option to import anyway.")
    end