From 52c6f1ff6c4d26eeae9c4c5b0312912185c14665 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Fri, 16 Sep 2022 16:39:08 -0400 Subject: [PATCH] Limit number of items in initial sync --- lib/frenzy_web/controllers/fervor/items_controller.ex | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/frenzy_web/controllers/fervor/items_controller.ex b/lib/frenzy_web/controllers/fervor/items_controller.ex index 0731e4c..a6ff02b 100644 --- a/lib/frenzy_web/controllers/fervor/items_controller.ex +++ b/lib/frenzy_web/controllers/fervor/items_controller.ex @@ -146,7 +146,13 @@ defmodule FrenzyWeb.Fervor.ItemsController do {deleted_ids, upserted} = case last_sync do nil -> - items = Repo.all(from i in Item, where: not i.tombstone and i.feed_id in ^feed_ids) + items = + Item + |> where([i], not i.tombstone and i.feed_id in ^feed_ids) + |> order_by([i], desc: i.inserted_at) + |> limit(1000) + |> Repo.all() + {[], items} _ ->