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