From 0ba8cfaf4f5bcfb31a8fa5850465f7c37090122e Mon Sep 17 00:00:00 2001 From: Andrea Vos Date: Sat, 21 Jun 2025 15:06:45 +0200 Subject: [PATCH] (census)(admin) allow downloading previous years --- server/express/census.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/express/census.ts b/server/express/census.ts index f6ef6c024..e5adb73ff 100644 --- a/server/express/census.ts +++ b/server/express/census.ts @@ -222,7 +222,7 @@ const calculateAggregate = (config: Aggregate, answer: Set): bo } }; -router.get('/census/export', handleErrorAsync(async (req, res) => { +router.get('/census/export/:edition?', handleErrorAsync(async (req, res) => { if (!req.isGranted('census')) { return res.status(401).json({ error: 'Unauthorised' }); } @@ -230,11 +230,13 @@ router.get('/census/export', handleErrorAsync(async (req, res) => { const locale = getLocale(getH3Event(req)); const config = await loadConfig(locale); + const edition = req.params.edition || config.census.edition; + const report = []; for (const { answers: answersRaw, writins: writinsRaw } of await req.db.all>(SQL` SELECT answers, writins FROM census WHERE locale = ${config.locale} - AND edition = ${config.census.edition} + AND edition = ${edition} AND suspicious = 0 AND troll = 0 AND relevant = 1