Skip to content

Websites chart automatic time grain - #1165

Merged
majakomel merged 17 commits into
masterfrom
websites_chart_time_grain
Oct 28, 2026
Merged

majakomel merged 17 commits into
masterfrom
websites_chart_time_grain

Conversation

@aagbsn

@aagbsn aagbsn commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

The country and network pages charted every tested domain per day whatever the date range. Pakistan since 2018 asked the API for 4.1 million rows, which ran an API task out of memory on 2026-10-08 (the browser got a 504 after 60s, and couldn't have drawn it anyway).

Beyond the default 30-day daily view, the websites chart now uses week up to 13 weeks, month up to 18 months, then year, which the charts now support. Most countries test about 2,500–2,800 domains a month, so these views stay under about 19 buckets, no larger than the default view, with room for growth. Each grain is one the API now accepts for its range (ooni/backend#1259)

The Apps and Circumvention charts stay daily: they have only 3–4 rows per bucket.

A new Playwright test opens Canada's country page from 2023 and checks the websites chart asks for year.

aagbsn added 2 commits October 8, 2026 12:09
The country and network pages charted every tested domain per day,
whatever the range: Pakistan since 2018 asked the API for 4.1 million
rows, which took down an API task (and the browser could not have drawn
it). Beyond the default 30-day daily view, use week up to 13 weeks,
month up to 18 months, then year, which the charts now support too.
Most countries test ~2,500-2,800 domains a month, so these charts stay
under about 19 buckets, around half the 100,000 rows the API will
return. Each of these is a grain the API accepts for that range.
@vercel

vercel Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
explorer Ready Ready Preview Oct 27, 2026 4:30pm UTC

Request Review

@aagbsn
aagbsn marked this pull request as draft October 8, 2026 12:28
The websites chart's "See on MAT" link can now carry time_grain=year,
but MAT's form only offered hour, day, week and month, and reset
anything else to day: a multi-year link turned into the multi-year
daily query the websites chart now avoids. Offer year for ranges over a
year, the only ranges the API accepts it for, without the slow query
warning, like month.

The options also came from the wrong range when the page was loaded
from a link: the form's date range state kept its 30-day defaults,
because the reset to the URL's values once the router is ready names
no field for the watch that updates it.
Changing the dates in MAT kept the time grain, so a range over years
still asked for a row per day unless the grain was changed by hand.
Picking dates now picks the grain the websites chart uses for that
range; it can still be changed afterwards, and links keep their own.

Use year from ranges over a year, where the API starts accepting it,
instead of over 18 months: charts with a row per domain then have at
most 13 buckets beyond the default view.
The date picker starts a new range on each click, so picking a start
day and pressing Apply gave a range without an end, and MAT cleared
until. With no complete range the time grain wasn't picked either.
Keep the current until instead.
@aagbsn
aagbsn requested a review from majakomel October 8, 2026 13:13
@aagbsn
aagbsn marked this pull request as ready for review October 8, 2026 13:13
@majakomel

Copy link
Copy Markdown
Contributor

I added several improvements on this branch:

  • renamed websitesTimeGrain to timeGrainForDateRange.
  • for the sake of consistency I updated also app charts on country pages to use same time grain, as well as network (ASN) pages, domain pages, thematic charts
  • improved MAT form handling (useWatch instead of duplicate useState copies)
  • fixed flaky home page test while at it (banner stats use fixed values when NEXT_PUBLIC_IS_TEST_ENV is set, so the test no longer depends on the live API, its 429s, or changing numbers)

@majakomel
majakomel merged commit 5c5ce0e into master Oct 28, 2026
3 checks passed
@majakomel
majakomel deleted the websites_chart_time_grain branch October 28, 2026 09:46

This branch was successfully deployed

1 active deployment
Preview — 1ec4e542 Deployed Oct 27, 2026 by vercel[bot]
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