chore: ignore failed imports

This commit is contained in:
Zach Daniel 2023-06-15 10:34:12 -04:00
parent 4689afa66b
commit 3832da271a

View file

@ -106,22 +106,25 @@ defmodule AshHq.Discord.Poller do
end) end)
|> Enum.each(fn %{thread: thread, messages: messages} -> |> Enum.each(fn %{thread: thread, messages: messages} ->
try do try do
author = author =
messages messages
|> Enum.min_by(& &1.timestamp, DateTime) |> Enum.min_by(& &1.timestamp, DateTime)
|> Map.get(:author) |> Map.get(:author)
thread thread
|> Map.put(:author, author) |> Map.put(:author, author)
|> Map.from_struct() |> Map.from_struct()
|> Map.put(:channel_id, thread.parent_id) |> Map.put(:channel_id, thread.parent_id)
|> Map.put(:tags, thread.applied_tags) |> Map.put(:tags, thread.applied_tags)
|> Map.put(:create_timestamp, thread.thread_metadata.create_timestamp) |> Map.put(:create_timestamp, thread.thread_metadata.create_timestamp)
|> Map.put(:messages, Enum.map(messages, &Map.from_struct/1)) |> Map.put(:messages, Enum.map(messages, &Map.from_struct/1))
|> AshHq.Discord.Thread.upsert!() |> AshHq.Discord.Thread.upsert!()
rescue rescue
e -> e ->
Logger.error("Failed to import message:\n #{Exception.format(:error, e, __STACKTRACE__)}") Logger.error(
"Failed to import message:\n #{Exception.format(:error, e, __STACKTRACE__)}"
)
end
end) end)
end end