Skip to content

feat: show click counts on the /.all and search listings#234

Open
simonepri wants to merge 1 commit into
tailscale:mainfrom
simonepri:feat/all-page-clicks-column
Open

feat: show click counts on the /.all and search listings#234
simonepri wants to merge 1 commit into
tailscale:mainfrom
simonepri:feat/all-page-clicks-column

Conversation

@simonepri
Copy link
Copy Markdown

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 /.all page 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 ./....

## 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>
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