also looking at this
fix(dashboard): the regions panel says California, not CA
#63
4 files
+145
-9
| @@ -17,7 +17,7 @@ import { CH_SEARCH, CH_SOCIAL, channelOf, channelPredicate, countryName, eventUr | ||
| 17 | 17 | import { installTargets } from '../../app/Analytics/install' |
| 18 | 18 | import { listReachableSites, listSiteMembers } from '../../app/Analytics/access' |
| 19 | 19 | import { planForSite } from '../../app/Analytics/entitlements' |
| 20 | import { foldRegions, splitRegion } from '../../app/Analytics/regions' | |
| 20 | import { foldRegions, splitRegion, subdivisionName } from '../../app/Analytics/regions' | |
| 21 | 21 | import { cityLabel, foldCities, splitCity } from '../../app/Analytics/cities' |
| 22 | 22 | import { liveSnapshot } from '../../app/Analytics/realtime' |
| 23 | 23 | import { niceCeil, xTicks, yTicks } from '../../app/Support/chart-axis' |
| @@ -983,14 +983,20 @@ const countryRows = countries.map((c) => { | ||
| 983 | 983 | * per-row floor when no other breakdown on this page does. The traffic still |
| 984 | 984 | * counts in the total; what is withheld is which state it came from. |
| 985 | 985 | * |
| 986 | * ## Why the label is a code and not a name | |
| 986 | * ## Why the label is a name and not a code | |
| 987 | 987 | * |
| 988 | 988 | * `US-CA` is what the column holds, what addFilterUrl puts in the query string, |
| 989 | * and what the filter matches, so the code has to survive on the row. Spelling | |
| 990 | * it out would mean shipping a table of every ISO 3166-2 subdivision name — some | |
| 991 | * four thousand of them — to render a panel that is off by default. The flag | |
| 992 | * carries the country and the code carries the state, which is how most of these | |
| 993 | * are written down anyway. | |
| 989 | * and what the filter matches — none of which is affected by how the row reads. | |
| 990 | * | |
| 991 | * It used to read as the bare code, because spelling it out "would mean shipping | |
| 992 | * a table of every ISO 3166-2 subdivision name". That table is already shipped: | |
| 993 | * `subdivisions.json`, which geo.ts has needed since region geo started working | |
| 994 | * at all. Read backwards it answers this question for nothing. | |
| 995 | * | |
| 996 | * The code was only ever legible by accident. `US-CA` passes for California to | |
| 997 | * an American reader; `PH-07` says nothing to anyone, and a bare `CA` beside a | |
| 998 | * flag is equally the code for Canada. A subdivision the table cannot name still | |
| 999 | * shows its code, which is honest about not knowing rather than inventing. | |
| 994 | 1000 | */ |
| 995 | 1001 | const REGION_FLOOR = siteFloor |
| 996 | 1002 | const foldedRegions = foldRegions(regions, REGION_FLOOR, 8) |
| @@ -1013,7 +1019,8 @@ const regionRows = foldedRegions.rows.map((r) => { | ||
| 1013 | 1019 | // built out of the wrong two letters. |
| 1014 | 1020 | if (!parts) |
| 1015 | 1021 | return { ...r, label: r.region } |
| 1016 | return { ...r, label: regionCountry ? parts.subdivision : `${flag(parts.country)} ${parts.subdivision}` } | |
| 1022 | const named = subdivisionName(r.region) ?? parts.subdivision | |
| 1023 | return { ...r, label: regionCountry ? named : `${flag(parts.country)} ${named}` } | |
| 1017 | 1024 | }) |
| 1018 | 1025 | if (foldedRegions.other) { |
| 1019 | 1026 | regionRows.push({ |