[bug] fix cache - don't use for admins

This commit is contained in:
Andrea Vos 2021-07-13 01:09:13 +02:00
parent 413237152a
commit 9566eee609
4 changed files with 5 additions and 5 deletions

View File

@ -32,7 +32,7 @@ router.get('/inclusive', handleErrorAsync(async (req, res) => {
AND i.approved >= ${req.isGranted('inclusive') ? 0 : 1} AND i.approved >= ${req.isGranted('inclusive') ? 0 : 1}
AND i.deleted = 0 AND i.deleted = 0
`), 'insteadOf'); `), 'insteadOf');
})); }, !req.isGranted('inclusive')));
})); }));
router.get('/inclusive/search/:term', handleErrorAsync(async (req, res) => { router.get('/inclusive/search/:term', handleErrorAsync(async (req, res) => {

View File

@ -80,7 +80,7 @@ router.get('/nouns', handleErrorAsync(async (req, res) => {
AND n.approved >= ${req.isGranted('nouns') ? 0 : 1} AND n.approved >= ${req.isGranted('nouns') ? 0 : 1}
ORDER BY n.approved, n.masc ORDER BY n.approved, n.masc
`)) `))
})); }, !req.isGranted('nouns')));
})); }));
router.get('/nouns/search/:term', handleErrorAsync(async (req, res) => { router.get('/nouns/search/:term', handleErrorAsync(async (req, res) => {

View File

@ -32,7 +32,7 @@ router.get('/terms', handleErrorAsync(async (req, res) => {
AND i.approved >= ${req.isGranted('terms') ? 0 : 1} AND i.approved >= ${req.isGranted('terms') ? 0 : 1}
AND i.deleted = 0 AND i.deleted = 0
`), 'term'); `), 'term');
})); }, !req.isGranted('terms')));
})); }));
router.get('/terms/search/:term', handleErrorAsync(async (req, res) => { router.get('/terms/search/:term', handleErrorAsync(async (req, res) => {

View File

@ -8,8 +8,8 @@ export class CacheObject {
this.maxAgeMinutes = maxAgeMinutes; this.maxAgeMinutes = maxAgeMinutes;
} }
async fetch(generator) { async fetch(generator, enabled = true) {
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development' || !enabled) {
return await generator(); return await generator();
} }