Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion src/app/benchmarks/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,31 @@ export default async function BenchmarkPage({
),
getBenchmarks(),
]);
const variants: Record<string, Benchmark> = Object.fromEntries(variantList);
// Variants only contribute chart / leaderboard / extras to the displayed
// bench (those legitimately differ per (chain, region) filter). Editorial
// copy (findings, faq, seoIntro, abstract, methodology) is the SAME on
// every tab and only resolves chain placeholders against the aggregate's
// bestPerChain/worstPerChain stash (computed unfiltered only), so we
// override these fields onto every variant. Without this, switching to
// a chain tab surfaces raw `{{best_name:chain:X}}` strings.
const variants: Record<string, Benchmark> = Object.fromEntries(
variantList.map(([key, v]) => [
key,
v === aggregate
? v
: {
...v,
findings: aggregate.findings,
faq: aggregate.faq,
seoIntro: aggregate.seoIntro,
abstract: aggregate.abstract,
methodology: aggregate.methodology,
perChainExplainer: aggregate.perChainExplainer,
bestPerChain: aggregate.bestPerChain,
worstPerChain: aggregate.worstPerChain,
},
]),
);
const benchmark = variants[variantKey(chain, region)] ?? aggregate;

const isDraft = benchmark.status === "draft";
Expand Down
18 changes: 9 additions & 9 deletions src/lib/spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,15 +371,15 @@ async function specToBenchmark(
let bestPerChain: Record<string, ProviderResult> | undefined;
let worstPerChain: Record<string, ProviderResult> | undefined;
let providersPerChain: Record<string, string[]> | undefined;
// Compute per-chain leaders for BOTH unfiltered and filtered views.
// Filtered variants are pre-fetched by the page (one per chain × region
// combo) and end up in the RSC payload; their findings/seo_intro/faq
// reference `{{best_name:chain:X}}` for ALL chains, not just the
// currently selected one, so each variant needs the full stash to
// resolve those placeholders. Cached per (slug, filterSig) via
// loadBenchmarkFiltered's unstable_cache so the extra Prom roundtrips
// are paid once per variant, not per request.
if (spec.dimensions?.chain && spec.dimensions.chain.length > 0) {
// Per-chain leaders/trailers/presence are computed ONLY on the
// unfiltered view. Earlier this also ran for filtered variants to
// populate {{best_name:chain:X}} in the variant's editorial copy,
// but that quadrupled Prom load per page (3 extra queries × 9
// pre-fetched variants on benches like aggregator-head-lag). The
// filtered variants now inherit findings/faq/seoIntro from the
// aggregate via the page-level fetch in app/benchmarks/[slug]/page.tsx,
// so per-chain compute on filtered variants is no longer needed.
if (!isFiltered && spec.dimensions?.chain && spec.dimensions.chain.length > 0) {
const chainValues = spec.dimensions.chain
.map((c) => c.value)
.filter((v) => v !== "all");
Expand Down
Loading