Stats picks a window and opens a day - #67
Merged
Merged
Conversation
A window is a span from a first day to a last one, or all time. Every number the screens read takes that span, so a whole window and one bar of its chart are read with the same functions. The series is drawn in days, weeks or months by the length of the span, the summary carries the span before it, top entries count the span and their people, and pages_read lists entries and other addresses together.
7, 30, 90 or 365 days or all time, chosen in the address. A clicked bar opens what was read in those days and where the readers came from under the chart, and the address remembers the bar. Top entries count the window with a people column, and the three figures say how the window moved against the one before. The editor draws its chart from the same series.
The first week or month bar of a long window reached back before the window, so the chart counted days the figures did not. The bar now starts where the window starts. Stats.step/1 says what a bar is from the span itself, so a fresh blog's single month bar is a month, with the year on its axis. Tests for both, for a fall against the window before, and for a number that is no window.
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 Stats screen showed the last thirty days and nothing else. No older numbers, no way to ask what happened on one day, and the top entries counted all time while every other table counted the window.
What it does now
?days=90), so the back button and a copied link keep it.&day=2026-08-18). A second click, or "close", shuts it.Nothing new is counted. Every number comes from the rows that were already there.
How
Texttile.Statsreads a span (%{from, to},from: nilfor all time) instead of a count of days.window/2builds one,series/2draws it in bars,bar/2finds the bar that holds a day, and a bar is itself a span, so the open bar is read with the samesummary/1,pages_read/1andreferrers/2as the whole window.StatsLivekeeps its whole state inhandle_params; a bar click is apush_patch. The editor's Stats tab draws its chart from the same series and is otherwise unchanged.Checked
mix precommit: 1443 tests, 0 failures. Unit tests for the span, the three bar sizes, the window before, the bar lookup andpages_read; LiveView tests for the address, the click, the close, a day outside the window, the comparison and the People column; the browser flow clicks a bar and switches the window.Version
3.0.5 to 3.1.0.
Claude Fable 5 in Claude Code did the work.