Skip to content

perf(cache): implement resource show caching, leaderboard cache, and dead cache cleanup - #437

Merged
trtajim merged 3 commits into
mainfrom
feat/resource-page-back-nav
Oct 24, 2026
Merged

trtajim merged 3 commits into
mainfrom
feat/resource-page-back-nav

Conversation

@trtajim

@trtajim trtajim commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Resource Details & Upvoters Caching: Caches public approved resource data and upvoters in ResourceController::show($id) for 6 hours.
  • Cache Invalidation: Flushes resource_public_{$id} on vote changes and through ResourceObserver on edit, status update (approval/rejection), or deletion.
  • Leaderboard Caching: Caches weekly and all-time leaderboard rankings for 30 minutes in LeaderboardController.
  • Curriculum & Notice Caching: Caches curriculum subjects for 24 hours and active banner notice with automatic observer invalidation.
  • Cleanup: Cleans obsolete controllers (SubjectController, NodeController), obsolete Inertia views (Home.vue, Node.vue), and obsolete cache keys in NodeObserver and CacheHelper.
  • UI Fix: Resolves dark mode prompt issue on Feed creation modal.

Summary by CodeRabbit

  • Performance
    • Subject lists, notices, leaderboards, and public resource details are now cached, which may improve page response times.
  • Bug Fixes
    • Resource pages now show subject and course details from the resource’s own subject when available.
    • Public resource details are refreshed after resource updates, votes, or deletion.
  • Updates
    • The desktop footer now appears on Feed and Notes pages instead of Home.
    • Node pages are no longer available, and nodes are no longer shareable from the floating share bar.
    • The leaderboard FAQ now clarifies that rankings update every 30 minutes.

@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Caution

Review failed

The pull request is closed.

Walkthrough

The changes update caching for curriculum subjects, notices, public resources, and leaderboard results. They remove the home and node controllers and pages, adjust layout and sharing behavior, and update resource metadata and leaderboard text.

Changes: Curriculum Pages and Cache Lifecycle

Layer / File(s) Summary
Curriculum subject caching
app/Helpers/CacheHelper.php, app/Http/Controllers/HomeController.php, app/Http/Controllers/NoteController.php
Home and notes subject queries are cached indefinitely by course and group. Curriculum-subject cache keys are cleared for both courses and all three groups.
Notice and node cache invalidation
app/Models/Notice.php, app/Observers/NoticeObserver.php, app/Observers/NodeObserver.php
Active notices are cached indefinitely and cleared when notices are saved or deleted. Node cache invalidation retains breadcrumb and homepage clearing while removing other listed invalidations.
Page removals and layout updates
app/Http/Controllers/SubjectController.php, app/Http/Controllers/NodeController.php, resources/js/pages/Home.vue, resources/js/pages/Node.vue, resources/js/components/FloatingShareBar.vue, resources/js/layouts/AppLayout.vue, resources/js/pages/Feed.vue
The home and node controllers and pages were removed. The footer now targets Feed and Notes/Index, Node pages are no longer shareable, and Feed button colors changed.

Public Resource Cache

Layer / File(s) Summary
Resource cache and invalidation
app/Http/Controllers/ResourceController.php, app/Observers/ResourceObserver.php, resources/views/app.blade.php, tests/Feature/PublicPagesTest.php
Resource pages cache approved resource data and upvoters for six hours, with an authorization fallback for non-approved resources. Votes and resource changes invalidate the cache. Metadata now prefers the resource’s subject, and the test asserts subject data under resource.subject.

Leaderboard Cache

Layer / File(s) Summary
Leaderboard caching and rank resolution
app/Http/Controllers/LeaderboardController.php, resources/js/pages/Leaderboard/Index.vue
Formatted leaderboard results are cached for 30 minutes. The controller resolves the current user’s score and rank separately. The timeframe FAQ states that rankings update every 30 minutes.

Priority: Pending latest changes

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Other

Possibly related PRs

  • hscstack/platform#435: Introduces the home and notes endpoints whose subject lists this PR caches.
  • hscstack/platform#430: Establishes the resource status and voting behavior used by the resource cache changes.
  • hscstack/platform#429: Introduces the resource subject relationship and page data used by the cache and metadata changes.
Merge Risk: Moderate · up to 921a4

Fix the resource page subject lookup for node-only resources, which currently fails a test. Also make sure private users disappear from cached leaderboards and that moving a node refreshes the curriculum subject list. The other cache findings are lower impact and can be handled alongside these.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@trtajim
trtajim force-pushed the feat/resource-page-back-nav branch from 7788bdd to 714bd7d Compare October 24, 2026 16:47
@trtajim
trtajim merged commit 5870968 into main Oct 24, 2026
5 checks passed
@trtajim
trtajim deleted the feat/resource-page-back-nav branch October 24, 2026 16:59
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.

1 participant