require IEx; IEx.pry()
-
Exit
pry
session inside anIEx
sessionrespawn
-
pry
in test suiteiex -S mix test --trace
-
Official docs
-
Debugging in views, tests, etc
require IEx; IEx.pry()
Exit pry
session inside an IEx
session
respawn
pry
in test suite
iex -S mix test --trace
Official docs
Debugging in views, tests, etc
Mapping.create_destination() |
docker-compose web mix run priv/repo/seeds.exs |
Atlas.Mapping.CSVUtil.csv_row_to_table_record("priv/repo/data/destinations.csv") |
defmodule Atlas.Mapping.CSVUtil do | |
@moduledoc """ | |
Utility module to ingest `destination.csv` | |
""" | |
alias NimbleCSV.RFC4180, as: CSV | |
alias Atlas.{Mapping, Mapping.Destination, Repo} | |
def csv_row_to_table_record(file) do | |
column_names = get_column_names(file) |
row["longitude"] |
defp create_or_skip(row) do | |
case Repo.get_by(Destination, | |
latitude: row["latitude"], | |
longitude: row["longitude"] | |
) do | |
nil -> | |
Mapping.create_destination(%{ | |
longitude: Decimal.new(row["longitude"]), | |
latitude: Decimal.new(row["latitude"]), | |
name: row["name"], |
|> create_or_skip() |
%{ | |
"allows_dogs" => "true", | |
"backpack_camp" => "true", | |
"car_camp" => "false", | |
"car_friendly" => "true", | |
"description" => "Rumors of big fish, probably early in season. ~ 2.5 hr hike. Latest notes: 20190909", | |
"dogs_off_leash" => "true", | |
"fee" => "false", | |
"greater_than_three_hours" => "false", | |
"hike_in" => "true", |
|> Map.new(fn {val, num} -> {column_names[num], val} end) |