Skip to content

Commit 3f3fff8

Browse files
committed
Limit inside Stream.unfold
1 parent 467b3fb commit 3f3fff8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/error_tracker/plugins/pruner.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ defmodule ErrorTracker.Plugins.Pruner do
8989
_pruned_occurrences_count =
9090
errors
9191
|> Ecto.assoc(:occurrences)
92-
|> limit(1000)
9392
|> prune_occurrences()
9493
|> Enum.sum()
9594

@@ -101,7 +100,8 @@ defmodule ErrorTracker.Plugins.Pruner do
101100

102101
defp prune_occurrences(occurrences_query) do
103102
Stream.unfold(occurrences_query, fn occurrences_query ->
104-
occurrences_ids = Repo.all(from occurrence in occurrences_query, select: occurrence.id)
103+
occurrences_ids =
104+
Repo.all(from occurrence in occurrences_query, select: occurrence.id, limit: 1000)
105105

106106
case Repo.delete_all(from o in Occurrence, where: o.id in ^occurrences_ids) do
107107
{0, _} -> nil

0 commit comments

Comments
 (0)