Skip to content

fix: cap related-row fetch in RelatedActivityLogSource (#14)#19

Open
AsmitNepali wants to merge 1 commit into1.xfrom
fix-issue-14
Open

fix: cap related-row fetch in RelatedActivityLogSource (#14)#19
AsmitNepali wants to merge 1 commit into1.xfrom
fix-issue-14

Conversation

@AsmitNepali
Copy link
Copy Markdown
Collaborator

Summary

Fixes #14. RelatedActivityLogSource::resolve() loaded all related rows into memory before querying the activity log, causing N+1 / memory blow-up for subjects with thousands of related rows (e.g., a Person with 10k tasks).

Change

src/Timeline/Sources/RelatedActivityLogSource.php:36 — add ->limit($window->cap) to the related-row fetch so it matches the cap already applied to the activity-log query downstream.

$rows = $subject->{$relation}()->limit($window->cap)->get();

Test plan

  • Existing tests/Feature/RelatedActivityLogSourceTest.php passes (3 tests, 4 assertions)
  • Verify behavior on a Person subject with >cap related rows in a downstream consumer

🤖 Generated with Claude Code

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.
@AsmitNepali AsmitNepali self-assigned this Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RelatedActivityLogSource loads all related rows unbounded — N+1 risk

1 participant