mirror of
https://github.com/bitbaum/substrata.git
synced 2026-12-04 14:18:33 +01:00
* fix(data): correct what the quality checks and a 36-row source sample found - listings: 8 pinned home lines stored a composite FIGI that OpenFIGI cannot resolve (openfigi.com/id 404, ID_BB_GLOBAL mapping empty); pinnedLine now keeps the exchange line's own FIGI (TSMC, UMC, GlobalWafers, ASE, SMIC, Rio Tinto, NKT, TSMC Advanced Packaging) - sanctions: all 49 EU amendment dates were a day early (Brussels-midnight stamps read in UTC); 4 OFAC programmes had empty titles (menu link parsed first) - usgs-producers: wrapped workbook cells were split into bogus facilities (64 fragments -> 5); Chile's copper table had lost Escondida, Spence, Sierra Gorda and 12 more rows behind a 'Continued' commodity cell - events/dependencies: 7 paraphrased quotes replaced with the source's verbatim text; SK Siltron event names its directory company - series: 18 Cameco points get the date their MD&A states - directory: Shin-Etsu Handotai source 404 replaced; Fangyuan careers URL (domain does not resolve) set to null as its evidence already said Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * feat(data): written quality criteria per dataset, automated checks, /data/quality - config/substrata-quality.ts: 15 datasets x 6 criteria (completeness, correctness, provenance, freshness, link health, consistency); each a rule or 'na' with a reason; freshness reuses config/substrata-freshness.ts - lib/quality: pure checks (USGS world sums, quote states the value, names resolve, cross-dataset agreement with USGS) run in verify with a failure-count ratchet (test/quality.test.ts); network checks (links with 3 tries and a blocked/broken distinction, quotes on page, SEC ticker file, OpenFIGI mapping, USGS values on the chapter PDF) run on a rotation via /api/cron/quality - migration 014: research_quality_checks + research_quality_runs (trend) - /data/quality: scores, counts, trend and every failing row with its source and a prefilled correction issue; linked from /data, footer, palette - check-series.ts shares the reader (CDATA and ' ,' fixes found by the sample) - pnpm run quality [-- --network | --all | --json out.json]; no AI anywhere Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
73 lines
2.5 KiB
TypeScript
73 lines
2.5 KiB
TypeScript
import { Figure } from '@/components/portal/Figure';
|
|
import { CRITERION_LABEL } from '@/config/substrata-quality';
|
|
import type { DatasetCard } from '@/lib/quality/report';
|
|
import { CRITERIA } from '@/lib/quality/types';
|
|
|
|
export const pctText = (n: number | null) =>
|
|
n === null ? '—' : `${n.toFixed(n === 100 ? 0 : 1)}%`;
|
|
|
|
/** A score's band, for its colour: the same three bands as the freshness dots. */
|
|
export function band(score: number | null): 'good' | 'fair' | 'poor' | 'none' {
|
|
if (score === null) return 'none';
|
|
if (score >= 98) return 'good';
|
|
if (score >= 90) return 'fair';
|
|
return 'poor';
|
|
}
|
|
|
|
/** Every dataset against every criterion, one screen. */
|
|
export function ScoreTable({ cards }: { cards: DatasetCard[] }) {
|
|
return (
|
|
<table className="fresh-table quality-table">
|
|
<thead>
|
|
<tr>
|
|
<th scope="col">Dataset</th>
|
|
<th scope="col">Score</th>
|
|
{CRITERIA.map((c) => (
|
|
<th scope="col" key={c}>
|
|
{CRITERION_LABEL[c].label}
|
|
</th>
|
|
))}
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{cards.map((card) => (
|
|
<tr key={card.dataset.id}>
|
|
<th scope="row">
|
|
<a className="fresh-name" href={`#q-${card.dataset.id}`}>
|
|
{card.dataset.label}
|
|
</a>
|
|
</th>
|
|
<td data-label="Score" className={`fresh-num quality-cell is-${band(card.overall)}`}>
|
|
<Figure method="quality-overall">{pctText(card.overall)}</Figure>
|
|
</td>
|
|
{card.scores.map((s) => {
|
|
const rule = card.dataset.criteria[s.criterion];
|
|
return (
|
|
<td
|
|
key={s.criterion}
|
|
data-label={CRITERION_LABEL[s.criterion].label}
|
|
className={`fresh-num quality-cell is-${band(s.score)}`}
|
|
title={typeof rule === 'string' ? rule : `Not measured: ${rule.na}`}
|
|
>
|
|
{s.score === null ? (
|
|
<span className="quality-na">
|
|
{typeof rule === 'string' ? 'not yet looked at' : 'not measured'}
|
|
</span>
|
|
) : (
|
|
<Figure
|
|
method="quality-score"
|
|
detail={`${s.passed} of ${s.checked} rows held.`}
|
|
>
|
|
{pctText(s.score)}
|
|
</Figure>
|
|
)}
|
|
</td>
|
|
);
|
|
})}
|
|
</tr>
|
|
))}
|
|
</tbody>
|
|
</table>
|
|
);
|
|
}
|