store neighbour info directly in the nodes table

This commit is contained in:
liamcottle
2024-03-23 22:56:03 +13:00
parent 22dceaac54
commit d7252c9962
3 changed files with 27 additions and 0 deletions

View File

@ -273,6 +273,7 @@ client.on("message", async (topic, message) => {
});
}
// create neighbour info
try {
await prisma.neighbourInfo.create({
data: {
@ -290,6 +291,26 @@ client.on("message", async (topic, message) => {
console.error(e);
}
// update node neighbour info in db
try {
await prisma.node.updateMany({
where: {
node_id: envelope.packet.from,
},
data: {
neighbour_broadcast_interval_secs: neighbourInfo.nodeBroadcastIntervalSecs,
neighbours: neighbourInfo.neighbors.map((neighbour) => {
return {
node_id: neighbour.nodeId,
snr: neighbour.snr,
};
}),
},
});
} catch (e) {
console.error(e);
}
}
else if(portnum === 67) {