~ihabunek/triglav

d258b57bfb6e76c5182888e6382a285f576b3550 — Ivan Habunek 10 months ago 0db0f4b
Add mix tasks for osmosis
2 files changed, 27 insertions(+), 0 deletions(-)

A lib/mix/tasks/triglav/osmosis_init.ex
A lib/mix/tasks/triglav/osmosis_update.ex
A lib/mix/tasks/triglav/osmosis_init.ex => lib/mix/tasks/triglav/osmosis_init.ex +14 -0
@@ 0,0 1,14 @@
defmodule Mix.Tasks.Triglav.OsmosisInit do
  use Mix.Task

  @shortdoc "(re)Creates the Osmosis schema and loads the initial data set"

  @impl Mix.Task
  def run(_args) do
    Application.put_env(:triglav, :minimal, true)
    {:ok, _} = Application.ensure_all_started(:triglav)

    Triglav.Import.Osmosis.create_schema()
    Triglav.Import.Osmosis.load_initial()
  end
end

A lib/mix/tasks/triglav/osmosis_update.ex => lib/mix/tasks/triglav/osmosis_update.ex +13 -0
@@ 0,0 1,13 @@
defmodule Mix.Tasks.Triglav.OsmosisUpdate do
  use Mix.Task

  @shortdoc "Updates the osmosis data to latest available."

  @impl Mix.Task
  def run(_args) do
    Application.put_env(:triglav, :minimal, true)
    {:ok, _} = Application.ensure_all_started(:triglav)

    Triglav.Import.Osmosis.update()
  end
end