feat: show click counts on the /.all and search listings#234
Open
simonepri wants to merge 1 commit into
Open
Conversation
## Problem The /.all listing (and the owner-search page) shows each link's short name, owner, and last-edited date, but not how many times it has been clicked. That popularity signal already exists and is surfaced on the home page's "Popular Links" table, but the home page is capped at the top 200, so it isn't visible when browsing the full set of links. ## Solution Annotate the links rendered by searchTmpl with their click counts and add a Clicks column to tmpl/search.html (desktop column plus a line in the mobile stacked view). Counts are read from the same in-memory stats.clicks counter the home page uses, so they reflect not-yet-flushed clicks without an extra DB query. A new searchResult type embeds *Link and carries NumClicks, and searchResults() annotates and orders the links most-clicked first (tie-broken by short name), replacing the per-handler alphabetical sort in serveAll and serveSearch. Signed-off-by: Simone Primarosa <simone.primarosa@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The home page already shows click counts in the Popular Links table, but that table is capped at the top 200 links and there's no way to see counts when browsing the full list. This adds a Clicks column to the
/.allpage so you can see how often each link actually gets used.The owner search page (
/.search?q=owner:...) renders the same template, so it gets the column too. Counts come from the same in-memory counter the home page reads, and the rows are now ordered most-clicked first to match the Popular Links ordering.Tested with
go test ./....