Add tab-based navigation with filter views (#40) #52
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "40-canvas-view-activity-sizing"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Closes #40
Changes
links_controller.rb: Filter logic viaparams[:filter]— popular (by click count), favorites, other (non-favorites), default (all ordered)application.html.erb: Four nav tabs with active state highlighting, "+ Add" buttonindex.html.erb: Dynamic heading per filter, contextual empty states_link.html.erb: Inline click count display after domainapplication.css:.link-card-clicksstyle using design tokensTest Plan
Review Checklist
Related Notes
PR #52 Review
DOMAIN REVIEW
Tech stack: Ruby on Rails (controllers, ERB views, CSS), Minitest.
N+1 query on
click_count: TheLink#click_countmethod (app/models/link.rb:11-13) callsclicks.count, which fires a separate SQL query per link. On the index page, every rendered_link.html.erbpartial callslink.click_count, producing N+1 queries. The "popular" filter already doesLink.left_joins(:clicks).group(:id).order("COUNT(clicks.id) DESC")-- but the computed count is only used for ordering, not selected into a result attribute. So even on the Popular tab, each card still fires its ownSELECT COUNT(*)query. Two approaches to fix:.select("links.*, COUNT(clicks.id) AS click_count")to the popular query and define a virtual attribute, ORcounter_cache: trueon theClickmodel (adds aclicks_countcolumn tolinks), ORincludes(:clicks)on the non-popular queries (trades N+1 SELECTs for loading all click records into memory, less ideal but functional).This is a performance concern that will degrade as the dataset grows. Not a blocker at current scale, but should be tracked.
Missing empty state for "popular" filter:
index.html.erbhandles empty states forfavoritesandother, butpopularfalls through to the default "No links yet. Add your first link" message, which is misleading for a filtered view.BLOCKERS
No tests for new functionality. The PR adds three new controller filter paths (
popular,other, default refactor) and a view-levelclick_countdisplay. Zero tests were added. The project already has a functioning test suite (test/controllers/links_controller_sort_test.rb,test/controllers/clicks_controller_test.rb,test/models/click_test.rb). Per review criteria, new functionality without test coverage is a blocker. Needed tests:GET /linksreturns all links in default orderGET /links?filter=popularreturns links sorted by click count descendingGET /links?filter=favoritesreturns only favorited linksGET /links?filter=otherreturns only non-favorited linksGET /links?filter=unknown_valuefalls through to default (edge case)NITS
0.75remfont-size not a design token:.link-card-clicksuses a raw0.75remvalue. This matches the existing.tagclass pattern so it is consistent with current conventions, but both could benefit from a--font-size-xstoken. Non-blocking.Popular query omits a fallback order:
Link.left_joins(:clicks).group(:id).order("COUNT(clicks.id) DESC")-- links with equal click counts have no deterministic secondary sort. Consider adding.order("COUNT(clicks.id) DESC, links.updated_at DESC")or similar for stable ordering.Heading map in view:
{ "popular" => "Popular", "favorites" => "Favorites", "other" => "Other" }[@current_filter] || "Links"works but creates a new hash on every request. Consider extracting to a helper method or constant. Minor.SOP COMPLIANCE
var(--color-muted),var(--spacing-sm))PROCESS OBSERVATIONS
40-canvas-view-activity-sizingmatches issue #40. Good traceability.VERDICT: NOT APPROVED
Reason: New filter logic (popular, other, default) and click count display have zero test coverage. Add controller integration tests for each filter path before re-review.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.