Repository navigation
feat(backend,frontend): show the estimated number of Tor users per country - #606
Merged
Merged
Conversation
Adds the country_usage table (V5), a scheduled import of Tor Metrics'
userstats-relay-country.csv and GET /relay/country-usage/day/{day}.
The import uses one configured URL without redirects, timeouts, a size limit
and strict per-line validation.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Adds a Tor users per country section to the settings. When enabled, countries are colored by Tor Metrics' estimate for the selected day on a logarithmic scale, with a plain text tooltip. The estimate's reliability (share of relays that contributed) is shown, and the layer degrades to a message if the backend does not provide the data. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Visit the preview URL for this PR (updated for commit fb75a1f): https://tormap-36f44--pr606-feat-country-usage-z790ot1w.web.app (expires Wed, 11 Nov 2026 21:51:38 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 0c1f71965de18e60b0e686b0d0356977fec090dc |
JuliusHenke
marked this pull request as ready for review
October 12, 2026 21:44
Resolve conflicts with the accessibility fixes and adapt the country usage layer to the lazily loaded country borders (#607): the borders only carry the country code now, so the tooltip takes the name from getFullCountryName, and the layer loads the borders with loadWorldFeatures instead of importing them into the main bundle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Fifth step of the TorFlow feature comparison. Adds Tor Metrics' estimated number of relay users per country as an optional map layer. This is the one new data source of the plan.
Data source
userstats-relay-country.csvfrom Tor Metrics (CC0):date,country,users,lower,upper,frac, daily from 2011-03-06, about 2 days behind. I checked the live file: ~1.3 M rows, ~38 MB, 247 country codes (including the empty global total,??and legacy codes). The method is documented at https://metrics.torproject.org/reproducible-metrics.html#relay-users: users are estimated from the directory requests relays report, so this counts users that connect to Tor directly, not the traffic they cause.fracis the share of the network that contributed (11 % in 2011, 50 to 75 % recently), so early values are less reliable. The UI shows this.Backend
country_usage(day, country_code, users, lower, upper, frac)(FlywayV5).CountryUsageService: the first run downloads the complete history, later runs only?start=<latest day - 14>(Tor Metrics revises recent days). Scheduled every 12 h like the other imports, upserts in chunks.??and legacy codes likea1/a2are skipped.GET /relay/country-usage/day/{day}returns[{country, users, lower, upper, frac}],dayis a strictly parsedLocalDate(400 otherwise),[]for days without estimates. Cached per day in a bounded cache (400 entries), cleared after each import.usage-statistics.*inapplication.yml.Frontend
Security (THREAT_MODEL.md updated)
New outbound call, checked against the review checklist:
[a-z]{2}country, bounded numbers, no future dates), malformed lines are skipped and counted, bound parameters only./relay/**;SecurityRulesTestincludes it. No change toSecurityConfig.Deployment notes
usage-statistics.baseUrlto another mirror is possible but not needed.Testing
start, cache clearing, 500, size limit, redirect not followed, future dates) and controller (data, empty, 400 for invalid days).tsc, ESLint andyarn buildclean. New tests for the color scale, layer and tooltip text, the loading component and the settings section.🤖 Generated with Claude Code