Skip to content

Show annotations in a partial first week bucket - #6966

Open
farisbasha wants to merge 1 commit into
plausible:masterfrom
farisbasha:fix-annotations-partial-first-week
Open

farisbasha wants to merge 1 commit into
plausible:masterfrom
farisbasha:fix-annotations-partial-first-week

Conversation

@farisbasha

Copy link
Copy Markdown

Changes

With the week interval, annotations in the first week of a period that starts mid-week are not shown on the main graph.

The backend labels that first, partial week bucket with the period start date (Plausible.Stats.Time.date_or_weekstart/2, e.g. a period from Sun 2020-12-20 gets the labels 2020-12-20, 2020-12-21, 2020-12-28, ...). getAnnotationDatetimeGroup always grouped annotations by start of week (2020-12-14), and MainGraph looks annotations up by the exact time label, so nothing matched that bucket.

Repro: pick "Month" for December 2026 (starts on a Tuesday) or "Last 28 days", switch the graph to "Week", and add an annotation on a day in the first bucket. The annotation is saved but no marker appears on the first bucket.

Fix: groupAnnotationsByDatetime / getAnnotationDatetimeGroup take an optional first time label; with the week interval, a date whose start of week falls before that label is grouped under it. MainGraph passes data.meta.time_labels[0]. Without the new argument the behaviour is unchanged.

Run in assets/: npm run test (37 suites, 584 tests pass; the new test fails before the fix with 2020-12-14 instead of 2020-12-20), npm run typecheck, npm run lint, npm run check-format.

This PR was prepared with AI assistance (Claude).

Tests

  • Automated tests have been added

Changelog

  • Entry has been added to changelog

Documentation

  • This change does not need a documentation update

Dark mode

  • This PR does not change the UI

The backend labels the first week bucket of a period that starts mid-week with the period start date (Plausible.Stats.Time.date_or_weekstart/2), but annotations were always grouped by start of week, so annotations in that partial first week never matched a graph bucket and were not shown. Group them under the first time label instead.
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

This branch has not been deployed

No deployments
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.

2 participants