Fix error when last sync is present but is invalid datetime

This commit is contained in:
Shadowfacts 2022-09-16 16:35:38 -04:00
parent 0e90ee527c
commit 3129142274
1 changed files with 6 additions and 4 deletions

View File

@ -135,10 +135,12 @@ defmodule FrenzyWeb.Fervor.ItemsController do
|> Repo.all()
last_sync =
Map.get(params, "last_sync")
|> case do
s when is_binary(s) -> Timex.parse!(s, "{ISO:Extended:Z}")
_ -> nil
with s when is_binary(s) <- Map.get(params, "last_sync"),
{:ok, datetime} <- Timex.parse(s) do
datetime
else
_ ->
nil
end
{deleted_ids, upserted} =