- Python 83.1%
- HTML 12.7%
- JavaScript 3.8%
- Mako 0.4%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| frontend | ||
| src | ||
| .gitignore | ||
| COPYING | ||
| COPYING.LESSER | ||
| MANIFEST.in | ||
| pyproject.toml | ||
| README.md | ||
splent_feature_statistics
The statistics feature of a SPLENT product line.
A SPLENT feature is a Python package that a product composes with others:
its models, routes, services, templates and hooks are registered when the
product starts. What this feature provides and requires is listed in the
[tool.splent.contract] section of pyproject.toml, which
splent feature:contract --write keeps in sync with the source.
Use it in a product
splent feature:add splent_feature_statistics
It requires dataset 0.4.0 or later, whose dataset-viewed and
dataset-downloaded it counts, and counts hubfile's hubfile-viewed and
hubfile-downloaded when the product has hubfile; public's home gives its
card a place. In the OpenHubs line it is an optional feature of repositorio,
with statistics => dataset. It names no artifact type and no rating: uvl,
factlabel and rating fill its slots when the product has them, so it
requires none of them.
Menus
statistics registers one entry in the framework's menu registry.
| Key | Section | Order | Icon | Opens | Shown to |
|---|---|---|---|---|---|
statistics |
site |
20 | bar-chart-2 |
/statistics, the dashboard |
Everyone |
A product hides or reorders it by key in its [tool.splent.layout.menu].
The shell draws it; statistics adds no sidebar hook of its own.
Its label has a Spanish translation in this feature's own catalog, "Escritorio", the word admin's catalog gives the same "Dashboard". Babel merges every feature's catalog into one, so a msgid has a single translation in a product and the two have to agree.
What it adds to other pages
- The "Hub statistics" card, in the side column of the home page
(
home.aside, the slot public's home opens beside its sections): the figures the dashboard's slots mark for the home.
The dashboard extends shell('app'), so a product that points the
application shell at another layout (SPLENT_SHELL_APP) moves it with it.
Its icons are feather's, which the application shell brings, and its looks
are Bootstrap 5.2's.
What it counts
Every figure is derived from the records, from one snapshot the dashboard
and the home card share (DC-7), cached for five minutes in
splent_feature_redis's cache (REDIS_CACHE_URL) and built by one process
at a time. It counts what anyone may read now (dataset's access policy):
no draft and nothing withdrawn. A dataset counts once per lineage, at the
version it shows, and its versions apart (D15); the authors are counted
once, by ORCID or by name, and an anonymous dataset names none. The series
are twelve months, the current one last, and a chart with nothing in it
says so instead.
uvlhub's table of six counters, written back on every visit, and its
counters-sync are gone (migration statistics0002_usage).
The registry of use
dataset and hubfile announce each visit and download with a signal, and
statistics records a visitor a day (DC-8): the account, or the address and
the agent of the browser, hashed with a salt of that day only. Drafts,
their owners' own visits and robots (an agent that names itself as one, or
names nothing) are not counted, and no cookie is set. The first visit of a
day rolls the days before up into usage_daily and deletes their events
and their salts; splent feature:statistics usage-rollup does it by hand.
usage_daily holds the hub's own days (source = "live") and the daily
aggregates the migration carries over from uvlhub 2.12 (legacy_v2,
DM-5). The dashboard counts both, and its "Where the use comes from" shows
each source apart with its note, which says how it was counted:
splent feature:statistics usage-note legacy_v2 "Use before 1 December 2026 comes from uvlhub.io 2.12 ..." --until 2026-11-30
Slots
What a hub of a kind adds comes from the features that know it, which fill
the dashboard's slots (slots.py) from their init_feature, so statistics
names none of them:
| Slot | What it is | In uvlhub |
|---|---|---|
register_kpi |
A number in the top row, and on the home card with home=True |
uvl's feature models |
register_top |
A table of datasets, best first | uvl's most models, rating's best and worst rated |
register_section |
A block of its own, with a template that may use statistics/_macros.html |
factlabel's characterisation of the corpus |
register_export |
A CSV and JSON download | factlabel's metrics of the corpus |
Each is computed once per snapshot, with a DashboardContext that names
the public versions and the version each lineage shows; a slot that fails
is left out and logged. Charts are plain data (chart(id, spec)), which
the dashboard's script draws, so a section brings no script.
/statistics/export.csv and /statistics/export.json (uvlhub 2.12's
addresses, CO-1) serve the first export, ?export=<key> another, and a
hub with none answers 404. The text cells of the CSV that a spreadsheet
would run as a formula start with an apostrophe.
Frontend
The dashboard's charts are assets/js/scripts.js, an ES module that
imports Chart.js (chart.js/auto, which registers every chart type). Chart.js
is an npm dependency, chart.js 4.5.1 in frontend/package.json, locked
in frontend/package-lock.json with what it brings (@kurkle/color), and
nothing of it is vendored. The SPLENT toolchain builds the entry
statistics (type module) into assets/dist/statistics.bundle.js, which
statistics/index.html loads with <script type="module">.
splent feature:compile statistics # build it once, in development mode
splent feature:compile statistics --watch # again on every change
splent feature:compile statistics --verify # the files match assets/meta/manifest.json
splent feature:npm statistics outdated # a newer Chart.js?
Develop
splent feature:test splent_feature_statistics
splent feature:contract splent_feature_statistics
Release
splent feature:release splent_feature_statistics --dry-run --bump patch
splent feature:release splent_feature_statistics
The first command rehearses the release and changes nothing. The second publishes it to the git forge and to PyPI, and a PyPI version is permanent.