for #101: check session cache for results

This commit is contained in:
groovecoder 2018-05-08 11:27:33 -05:00
Родитель ffa17064a6
Коммит 171c506273
2 изменённых файлов: 11 добавлений и 1 удалений

Просмотреть файл

@ -134,6 +134,8 @@ const DBUtils = {
return await aEntry
.$relatedQuery("breaches")
.orderBy("name");
}, async () => {
return [];
});
},

Просмотреть файл

@ -27,8 +27,16 @@ router.get("/monitor", urlEncodedParser, handleIndexRoute);
router.post("/scan", urlEncodedParser, async (req, res) => {
const email = req.body.email;
let foundBreaches;
if (email) {
foundBreaches = await DBUtils.getBreachesForEmail(email);
if (req.session.scanResults && req.session.scanResults[email]) {
foundBreaches = req.session.scanResults[email];
} else {
req.session.scanResults = {};
console.log("querying database for breaches");
foundBreaches = await DBUtils.getBreachesForEmail(email);
req.session.scanResults[email] = foundBreaches;
}
}
res.render("scan", {