Skip to content

Instantly share code, notes, and snippets.

@noelworden
Last active November 30, 2020 23:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noelworden/58fc85f8ca5e1e9cf3b8727a58f79f41 to your computer and use it in GitHub Desktop.
Save noelworden/58fc85f8ca5e1e9cf3b8727a58f79f41 to your computer and use it in GitHub Desktop.
#blog_snippets
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"],
description: row["description"],
spinner_friendly: row["spinner_friendly"],
lake: row["lake"],
less_than_one_hour: row["less_than_one_hour"],
one_to_three_hours: row["one_to_three_hours"],
greater_than_three_hours: row["greater_than_three_hours"],
car_friendly: row["car_friendly"],
hike_in: row["hike_in"],
allows_dogs: row["allows_dogs"],
dogs_off_leash: row["dogs_off_leash"],
season_spring: row["season_spring"],
season_summer: row["season_summer"],
season_fall: row["season_fall"],
season_winter: row["season_winter"],
car_camp: row["car_camp"],
backpack_camp: row["backpack_camp"],
fee: row["fee"],
ice_fishing: row["ice_fishing"]
})
destination ->
{:ok, destination}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment