🐛 fixed recaching of ctdo due to a shit api

This commit is contained in:
ryzetech 2023-01-24 10:55:52 +01:00
parent ce19124286
commit d1ac9663a9

6
app.js
View file

@ -71,9 +71,7 @@ async function loop() {
console.error(`The space ${space.id} might not be reachable. Please check the endpoint.`); console.error(`The space ${space.id} might not be reachable. Please check the endpoint.`);
continue; continue;
} }
if (JSON.stringify(response) != JSON.stringify(cache.get(space.id))) { if (response.open != cache.get(space.id)) {
cache.set(space.id, response);
// update or create the space in the database // update or create the space in the database
let update = await prisma.space.upsert({ let update = await prisma.space.upsert({
where: { id: space.id }, where: { id: space.id },
@ -92,7 +90,9 @@ async function loop() {
}); });
changecount++; changecount++;
console.debug(`Space ${space.id} changed to ${response.open ? "open" : "closed"}.`);
} }
cache.set(space.id, response.open);
} }
console.log(new Date(), "Check complete, updated", changecount, "spaces."); console.log(new Date(), "Check complete, updated", changecount, "spaces.");
} }