diff --git a/lib/frenzy/update_feeds.ex b/lib/frenzy/update_feeds.ex index 1adc8f0..bc3e612 100644 --- a/lib/frenzy/update_feeds.ex +++ b/lib/frenzy/update_feeds.ex @@ -83,7 +83,7 @@ defmodule Frenzy.UpdateFeeds do Logger.debug("Got 301 redirect from #{feed.feed_url} to #{new_url}, updating feed URL") changeset = Feed.changeset(feed, %{feed_url: new_url}) - {:ok, feed} = Repo.insert(changeset) + {:ok, feed} = Repo.update(changeset) update_feed(feed) {:error, %HTTPoison.Error{reason: reason}} -> @@ -129,7 +129,7 @@ defmodule Frenzy.UpdateFeeds do content {:err, reason} -> - Logger.warn("Unable to fetch article for #{url}: #{reason}") + Logger.warn("Unable to fetch article for #{url}: #{inspect(reason)}") entry.description end @@ -200,7 +200,7 @@ defmodule Frenzy.UpdateFeeds do end end - defp get_article_content(url) do + defp get_article_content(url) when is_binary(url) and url != "" do Logger.debug("Getting article from #{url}") case HTTPoison.get(url) do @@ -228,4 +228,6 @@ defmodule Frenzy.UpdateFeeds do {:err, reason} end end + + defp get_article_content(_url), do: {:err, "URL must be a non-empty string"} end