Skip to content

perf(files): use bounded favorite searches in dashboard widget and activity helper#59633

Draft
joshtrichards wants to merge 3 commits intomasterfrom
jtr/perf-favorites
Draft

perf(files): use bounded favorite searches in dashboard widget and activity helper#59633
joshtrichards wants to merge 3 commits intomasterfrom
jtr/perf-favorites

Conversation

@joshtrichards
Copy link
Copy Markdown
Member

@joshtrichards joshtrichards commented Apr 14, 2026

  • Resolves: #

Summary

Replace favorites ID lookup + per-node resolution with bounded file search queries in the Favorites widget and the activity helper.

What Changes

Previously these code paths:

  • loaded favorite file IDs via tags
  • resolved nodes one-by-one with getFirstNodeById()
  • applied limits in PHP

This PR switches them to use the existing files search stack directly with:

  • favorite = true
  • explicit limit / offset
  • explicit ordering (mtime DESC)

Why

This keeps the work bounded at the query layer and avoids repeated node lookups for small UI surfaces like the dashboard widget and favorites-based activity filtering.

Profiler traces on the dashboard widget showed the old implementation producing repeated filecache lookups per favorite, while the refactored implementation produces a single bounded query.

Notes

  • Activity\Helper preserves the existing FAVORITE_LIMIT behavior by querying FAVORITE_LIMIT + 1 and still throwing "Too many favorites" if exceeded.
  • This also makes favorite ordering deterministic. Previously the order from getFavorites() / getIdsForTag() was effectively unspecified.

Folow-up

  • A future cleanup could add a shared files-layer helper/API for favorite-node searches so this query construction does not need to be repeated at call sites.
  • There may be some opportunity to reduce queries elsewhere in the Activity look-ups used for the UI.

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant