Fix update feeds thinking all items already exist
Repo.exists? needs a query, not the keyword list
This commit is contained in:
parent
a02ec174be
commit
ddceb28803
|
@ -1,6 +1,7 @@
|
||||||
defmodule Frenzy.Item do
|
defmodule Frenzy.Item do
|
||||||
use Ecto.Schema
|
use Ecto.Schema
|
||||||
import Ecto.Changeset
|
import Ecto.Changeset
|
||||||
|
import Ecto.Query
|
||||||
alias FrenzyWeb.Router.Helpers, as: Routes
|
alias FrenzyWeb.Router.Helpers, as: Routes
|
||||||
alias FrenzyWeb.Endpoint
|
alias FrenzyWeb.Endpoint
|
||||||
|
|
||||||
|
@ -87,6 +88,6 @@ defmodule Frenzy.Item do
|
||||||
end
|
end
|
||||||
|
|
||||||
def exists?(feed_id, guid) do
|
def exists?(feed_id, guid) do
|
||||||
Frenzy.Repo.exists?(__MODULE__, feed_id: feed_id, guid: guid)
|
Frenzy.Repo.exists?(from i in __MODULE__, where: i.feed_id == ^feed_id and i.guid == ^guid)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -159,7 +159,6 @@ defmodule Frenzy.UpdateFeeds do
|
||||||
end
|
end
|
||||||
|
|
||||||
Enum.each(rss.items, fn entry ->
|
Enum.each(rss.items, fn entry ->
|
||||||
# todo: use Repo.exists for this
|
|
||||||
unless Item.exists?(feed.id, entry.guid) do
|
unless Item.exists?(feed.id, entry.guid) do
|
||||||
CreateItem.start_link(feed, entry)
|
CreateItem.start_link(feed, entry)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue