Limit Fever unread items API to 10k most recent
This commit is contained in:
parent
8e18a415eb
commit
375406a8df
|
@ -196,7 +196,12 @@ defmodule FrenzyWeb.FeverController do
|
||||||
|> Enum.map(fn f -> f.id end)
|
|> Enum.map(fn f -> f.id end)
|
||||||
|
|
||||||
unread =
|
unread =
|
||||||
Repo.all(from i in Item, where: i.feed_id in ^feed_ids, where: [read: false])
|
Repo.all(
|
||||||
|
from i in Item,
|
||||||
|
where: i.feed_id in ^feed_ids and not i.read,
|
||||||
|
limit: 10000,
|
||||||
|
order_by: [desc: :id]
|
||||||
|
)
|
||||||
|> Enum.map(fn item -> item.id end)
|
|> Enum.map(fn item -> item.id end)
|
||||||
|> Enum.join(",")
|
|> Enum.join(",")
|
||||||
|
|
||||||
|
@ -222,19 +227,20 @@ defmodule FrenzyWeb.FeverController do
|
||||||
items =
|
items =
|
||||||
cond do
|
cond do
|
||||||
Map.has_key?(params, "with_ids") ->
|
Map.has_key?(params, "with_ids") ->
|
||||||
|
item_ids =
|
||||||
params["with_ids"]
|
params["with_ids"]
|
||||||
|> String.split(",")
|
|> String.split(",")
|
||||||
|> Enum.map(fn id ->
|
|> Enum.map(fn str ->
|
||||||
{id, _} = id |> String.trim() |> Integer.parse()
|
{id, _} = str |> String.trim() |> Integer.parse()
|
||||||
item = Repo.get(Item, id)
|
id
|
||||||
|
|
||||||
if not is_nil(item) and item.feed_id in feed_ids do
|
|
||||||
item
|
|
||||||
else
|
|
||||||
nil
|
|
||||||
end
|
|
||||||
end)
|
end)
|
||||||
|> Enum.reject(&is_nil/1)
|
|
||||||
|
Repo.all(
|
||||||
|
from i in Item,
|
||||||
|
where: i.id in ^item_ids,
|
||||||
|
where: i.feed_id in ^feed_ids,
|
||||||
|
where: not i.tombstone
|
||||||
|
)
|
||||||
|
|
||||||
Map.has_key?(params, "since_id") ->
|
Map.has_key?(params, "since_id") ->
|
||||||
since = Repo.get(Item, params["since_id"])
|
since = Repo.get(Item, params["since_id"])
|
||||||
|
|
Loading…
Reference in New Issue