for #101: check session cache for results
This commit is contained in:
Родитель
ffa17064a6
Коммит
171c506273
|
@ -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", {
|
||||
|
|
Загрузка…
Ссылка в новой задаче