From a5f14e576cc036fd97c95ab55496837f086ca45c Mon Sep 17 00:00:00 2001 From: Brendan Samek Date: Mon, 19 Oct 2026 15:09:30 -0600 Subject: [PATCH] Allow a poll's uploaded report PDF through the download proxy York Factory now serves an uploaded report PDF (report_pdf_en/fr) as a poll's analysis_pdf when one is attached, in place of the generated report and the crosstab Excel/JSON. The proxy only forwards known assets, so it must accept the new names. The poll page needs no change: the existing "Download Report (PDF)" link points at whichever file York Factory names. Co-Authored-By: Claude Opus 5.5 --- src/lib/polls/downloads.test.ts | 10 ++++++++++ src/lib/polls/downloads.ts | 3 +++ 2 files changed, 13 insertions(+) diff --git a/src/lib/polls/downloads.test.ts b/src/lib/polls/downloads.test.ts index 1b51a51..71324c7 100644 --- a/src/lib/polls/downloads.test.ts +++ b/src/lib/polls/downloads.test.ts @@ -35,3 +35,13 @@ test("French requests preserve the API's English PDF fallback", () => { }); assert.deepEqual(mapPollDownloads("poll", {}), {}); }); + +test("an uploaded report PDF is served as the poll's report download", () => { + const downloads = mapPollDownloads("poll", { + analysis_pdf: "https://example.com/api/v1/polls/poll/downloads/report_pdf_en?locale=fr&publication=build_canada", + }); + assert.deepEqual(downloads, { + analysis_pdf: "/api/polls/poll/downloads/report_pdf_en?locale=fr&publication=build_canada", + }); + assert.ok(POLL_DOWNLOAD_ASSETS.has("report_pdf_en") && POLL_DOWNLOAD_ASSETS.has("report_pdf_fr")); +}); diff --git a/src/lib/polls/downloads.ts b/src/lib/polls/downloads.ts index 0b3d994..5942b3c 100644 --- a/src/lib/polls/downloads.ts +++ b/src/lib/polls/downloads.ts @@ -4,6 +4,9 @@ export const POLL_DOWNLOAD_ASSETS = new Set([ "analysis_markdown", "analysis_pdf_en", "analysis_pdf_fr", + // Published report PDF; when a poll has one, York Factory serves it as analysis_pdf. + "report_pdf_en", + "report_pdf_fr", "crosstabs_pdf_en", "crosstabs_pdf_fr", "crosstabs_json",