mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-10 16:05:32 -04:00
(census)(admin) allow downloading previous years
This commit is contained in:
parent
a04c412fc3
commit
0ba8cfaf4f
@ -222,7 +222,7 @@ const calculateAggregate = (config: Aggregate, answer: Set<number | string>): bo
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
router.get('/census/export', handleErrorAsync(async (req, res) => {
|
router.get('/census/export/:edition?', handleErrorAsync(async (req, res) => {
|
||||||
if (!req.isGranted('census')) {
|
if (!req.isGranted('census')) {
|
||||||
return res.status(401).json({ error: 'Unauthorised' });
|
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 locale = getLocale(getH3Event(req));
|
||||||
const config = await loadConfig(locale);
|
const config = await loadConfig(locale);
|
||||||
|
|
||||||
|
const edition = req.params.edition || config.census.edition;
|
||||||
|
|
||||||
const report = [];
|
const report = [];
|
||||||
for (const { answers: answersRaw, writins: writinsRaw } of await req.db.all<Pick<CensusRow, 'answers' | 'writins'>>(SQL`
|
for (const { answers: answersRaw, writins: writinsRaw } of await req.db.all<Pick<CensusRow, 'answers' | 'writins'>>(SQL`
|
||||||
SELECT answers, writins FROM census
|
SELECT answers, writins FROM census
|
||||||
WHERE locale = ${config.locale}
|
WHERE locale = ${config.locale}
|
||||||
AND edition = ${config.census.edition}
|
AND edition = ${edition}
|
||||||
AND suspicious = 0
|
AND suspicious = 0
|
||||||
AND troll = 0
|
AND troll = 0
|
||||||
AND relevant = 1
|
AND relevant = 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user