From 4efe34e7c263796c3765988239567e1cc34abb89 Mon Sep 17 00:00:00 2001 From: AsmitNepali Date: Tue, 28 Apr 2026 21:56:07 +0545 Subject: [PATCH] fix: cap related-row fetch in RelatedActivityLogSource (#14) Add ->limit($window->cap) to related-row query to avoid loading all related rows into memory when only $window->cap activity entries are needed downstream. Matches existing cap on the activity-log query. --- src/Timeline/Sources/RelatedActivityLogSource.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Timeline/Sources/RelatedActivityLogSource.php b/src/Timeline/Sources/RelatedActivityLogSource.php index 5286678..98950ea 100644 --- a/src/Timeline/Sources/RelatedActivityLogSource.php +++ b/src/Timeline/Sources/RelatedActivityLogSource.php @@ -33,7 +33,7 @@ public function resolve(Model $subject, Window $window): iterable $morphClass = (new $relatedClass)->getMorphClass(); /** @var EloquentCollection $rows */ - $rows = $subject->{$relation}()->get(); + $rows = $subject->{$relation}()->limit($window->cap)->get(); foreach ($rows as $row) { $subjectPairs[] = [$morphClass, (string) $row->getKey()];