Skip to content

Commit

Permalink
chore: ignore failed imports
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed Jun 15, 2023
1 parent 4689afa commit 3832da2
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions lib/ash_hq/discord/poller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -106,22 +106,25 @@ defmodule AshHq.Discord.Poller do
end)
|> Enum.each(fn %{thread: thread, messages: messages} ->
try do
author =
messages
|> Enum.min_by(& &1.timestamp, DateTime)
|> Map.get(:author)

thread
|> Map.put(:author, author)
|> Map.from_struct()
|> Map.put(:channel_id, thread.parent_id)
|> Map.put(:tags, thread.applied_tags)
|> Map.put(:create_timestamp, thread.thread_metadata.create_timestamp)
|> Map.put(:messages, Enum.map(messages, &Map.from_struct/1))
|> AshHq.Discord.Thread.upsert!()
author =
messages
|> Enum.min_by(& &1.timestamp, DateTime)
|> Map.get(:author)

thread
|> Map.put(:author, author)
|> Map.from_struct()
|> Map.put(:channel_id, thread.parent_id)
|> Map.put(:tags, thread.applied_tags)
|> Map.put(:create_timestamp, thread.thread_metadata.create_timestamp)
|> Map.put(:messages, Enum.map(messages, &Map.from_struct/1))
|> AshHq.Discord.Thread.upsert!()
rescue
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

Expand Down

0 comments on commit 3832da2

Please sign in to comment.