Compare commits
No commits in common. "a02ec174beb9a2a1037e30c87f3a8b6a3fa69ea8" and "bf98614de9389d563e51f96e43f9cf7d399cf897" have entirely different histories.
a02ec174be
...
bf98614de9
|
@ -83,10 +83,5 @@ defmodule Frenzy.Item do
|
|||
item
|
||||
|> cast(attrs, [:guid, :title, :url, :creator, :date, :content, :read, :read_date, :tombstone])
|
||||
|> validate_required([:guid, :url, :date, :content, :feed])
|
||||
|> unique_constraint(:items_feed_guid_index)
|
||||
end
|
||||
|
||||
def exists?(feed_id, guid) do
|
||||
Frenzy.Repo.exists?(__MODULE__, feed_id: feed_id, guid: guid)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -62,7 +62,7 @@ defmodule Frenzy.Task.CreateItem do
|
|||
end
|
||||
|
||||
case result do
|
||||
{:error, error} ->
|
||||
{:err, error} ->
|
||||
Logger.error(error)
|
||||
|
||||
{:ok, item_params} ->
|
||||
|
|
|
@ -53,6 +53,8 @@ defmodule Frenzy.UpdateFeeds do
|
|||
|
||||
Logger.info("Updating #{count} feeds")
|
||||
|
||||
Enum.each(feeds, &update_feed/1)
|
||||
|
||||
Enum.each(feeds, fn feed ->
|
||||
try do
|
||||
update_feed(feed)
|
||||
|
@ -158,9 +160,11 @@ defmodule Frenzy.UpdateFeeds do
|
|||
FetchFavicon.run(feed)
|
||||
end
|
||||
|
||||
feed = Repo.preload(feed, [:items])
|
||||
|
||||
Enum.each(rss.items, fn entry ->
|
||||
# todo: use Repo.exists for this
|
||||
unless Item.exists?(feed.id, entry.guid) do
|
||||
if !Enum.any?(feed.items, fn item -> item.guid == entry.guid end) do
|
||||
CreateItem.start_link(feed, entry)
|
||||
end
|
||||
end)
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
defmodule Frenzy.Repo.Migrations.CreatItemUniqueIndex do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create unique_index(:items, [:feed_id, :guid], name: :items_feed_guid_index)
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue