tidying stray dev code

This commit is contained in:
Adam Piontek 2021-03-25 18:09:53 -04:00
parent 326b6624b5
commit 3b5794a401

View file

@ -13,22 +13,21 @@ defmodule Shift73kWeb.ShiftImportLive.Index do
socket
|> assign_defaults(session)
|> assign(:url_valid, :false)
|> assign(:url_validated, :false)
|> assign(:tz_valid, :true)
|> assign(:url_valid, false)
|> assign(:url_validated, false)
|> assign(:tz_valid, true)
|> live_okreply()
end
@impl true
def handle_event("validate", %{"ics_import" => %{"ics_url" => url, "time_zone" => tz}}, socket) do
socket
|> assign(:url_valid, Regex.match?(@url_regex, url) |> IO.inspect(label: "url valid?"))
|> assign(:url_valid, Regex.match?(@url_regex, url))
|> assign(:url_validated, true)
|> assign(:tz_valid, Enum.member?(Tzdata.zone_list(), tz))
|> live_noreply()
end
@impl true
def handle_event("save", %{"ics_import" => %{"ics_url" => url, "time_zone" => tz}}, socket) do
url
@ -57,16 +56,12 @@ defmodule Shift73kWeb.ShiftImportLive.Index do
defp handle_parsed_ics_data([], socket, tz), do: handle_http_ics_response(false, socket, tz)
defp handle_parsed_ics_data(events, socket, tz) do
IO.inspect(events, label: "We got some ical events! :")
IO.inspect(tz, label: "time zone was :")
to_insert =
events
|> Stream.map(&shift_from_event(&1, tz, socket.assigns.current_user.id))
|> Enum.map(&Repo.timestamp/1)
|> Shifts.create_multiple()
|> handle_create_multiple_result(length(events), socket)
|> live_noreply()
events
|> Stream.map(&shift_from_event(&1, tz, socket.assigns.current_user.id))
|> Enum.map(&Repo.timestamp/1)
|> Shifts.create_multiple()
|> handle_create_multiple_result(length(events), socket)
|> live_noreply()
end
defp handle_create_multiple_result(result, event_count, socket) do
@ -81,14 +76,16 @@ defmodule Shift73kWeb.ShiftImportLive.Index do
if n == event_count do
{:success, "Successfully imported #{n} event#{s}"}
else
{:warning, "Some error, only #{n} event#{s} imported but seemed like iCal contained #{event_count}?"}
{:warning,
"Some error, only #{n} event#{s} imported but seemed like iCal contained #{
event_count
}?"}
end
end
put_flash(socket, status, msg)
end
defp content_type_calendar?(headers) do
headers
|> List.keyfind("Content-Type", 0)