Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
File size: 2,590 Bytes
d15f07c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | // The recording-coverage line (#1348): how many local governments and recorded meetings sit behind a story's counts, so a
// small count ("10 meetings in Florida") reads as a count of our recordings, not of everything said. Every number comes from
// GET /api/coverage/recorded-meetings; when it is unavailable the line is not shown (never a made-up figure). No "of N"
// denominator: the jurisdictions mart counts census places as cities, so it is not a reliable count of governments
// (web_docs/docs/guides/data-stories.md, "Recording coverage").
import type { RecordedCoverageResponse } from '../api/sitesTimeline'
export interface CoverageScope {
stateCode?: string
stateName: string | null
city: string | null
}
export interface CoverageText {
/** The full sentence(s), for wide screens. */
full: string
/** A short form for phones. */
short: string
}
const fmt = (n: number) => n.toLocaleString('en-US')
const govs = (n: number, place = '') => `${fmt(n)} ${place ? `${place} ` : ''}local ${n === 1 ? 'government' : 'governments'}`
const meetings = (n: number) => `${fmt(n)} ${n === 1 ? 'meeting' : 'meetings'}`
/** The line for the scope, or null when the counts are unavailable. */
export function coverageText(cov: RecordedCoverageResponse | null | undefined, scope: CoverageScope): CoverageText | null {
if (!cov || !cov.available || cov.governments == null || cov.meetings == null) return null
const g = cov.governments
const m = cov.meetings
const city = scope.stateCode ? scope.city : null
if (city) {
if (g === 0) return { full: `No ${city} local government is in our meeting recordings yet.`, short: `No ${city} recordings yet.` }
return { full: `From recordings of ${govs(g, city)} (${meetings(m)}).`, short: `Recorded: ${meetings(m)}.` }
}
if (scope.stateCode) {
const name = scope.stateName ?? scope.stateCode
if (g === 0) return { full: `No ${name} local government is in our meeting recordings yet.`, short: `No ${scope.stateCode} recordings yet.` }
return {
full: `From recordings of ${govs(g, name)} (${meetings(m)}). Many ${name} governments aren't in our recordings yet.`,
short: `From ${fmt(g)} ${scope.stateCode} ${g === 1 ? 'government' : 'governments'}' recordings (${meetings(m)}); many aren't in yet.`,
}
}
const states = cov.states && cov.states > 1 ? ` in ${fmt(cov.states)} states` : ''
return {
full: `From recordings of ${govs(g)}${states} (${meetings(m)}). Many governments aren't in our recordings yet.`,
short: `Recorded: ${fmt(g)} governments, ${meetings(m)}.`,
}
}
|