From 3cd6495d3ad42a5254192fbb84d39dd8c3de01ea Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sat, 6 Jun 2020 13:45:22 -0400 Subject: [PATCH] Rescue from error updating feeds --- lib/frenzy/update_feeds.ex | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/frenzy/update_feeds.ex b/lib/frenzy/update_feeds.ex index 00b0eeb..d28c0b5 100644 --- a/lib/frenzy/update_feeds.ex +++ b/lib/frenzy/update_feeds.ex @@ -38,9 +38,7 @@ defmodule Frenzy.UpdateFeeds do end defp update_feeds() do - Logger.info("Updating all feeds") - - {_count, feeds} = + {count, feeds} = Feed |> where( [f], @@ -50,7 +48,20 @@ defmodule Frenzy.UpdateFeeds do |> select([f], f) |> Repo.update_all(set: [last_refreshed_at: DateTime.utc_now()]) - Enum.map(feeds, &update_feed/1) + Logger.info("Updating #{count} feeds") + + Enum.each(feeds, &update_feed/1) + + Enum.each(feeds, fn feed -> + try do + update_feed(feed) + rescue + error -> + Logger.warn( + "Encountered error updating feed #{feed.id} #{feed.feed_url}: #{inspect(error)}" + ) + end + end) prune_old_items() end