Sekundäreinsatz wird nun richtig angezeigt
This commit is contained in:
@@ -52,10 +52,31 @@ const removeClosedMissions = async () => {
|
||||
console.log(`Mission ${mission.id} closed due to inactivity.`);
|
||||
});
|
||||
};
|
||||
const removeConnectedAircrafts = async () => {
|
||||
const connectedAircrafts = await prisma.connectedAircraft.findMany({
|
||||
where: {
|
||||
logoutTime: null,
|
||||
},
|
||||
});
|
||||
|
||||
connectedAircrafts.forEach(async (aircraft) => {
|
||||
const lastUpdate = new Date(aircraft.lastHeartbeat);
|
||||
const now = new Date();
|
||||
if (now.getTime() - lastUpdate.getTime() > 12 * 60 * 60 * 1000) {
|
||||
await prisma.connectedAircraft.update({
|
||||
where: { id: aircraft.id },
|
||||
data: { logoutTime: now },
|
||||
});
|
||||
|
||||
console.log(`Aircraft ${aircraft.id} disconnected due to inactivity.`);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
cron.schedule("*/5 * * * *", async () => {
|
||||
try {
|
||||
await removeClosedMissions();
|
||||
await removeConnectedAircrafts();
|
||||
} catch (error) {
|
||||
console.error("Error removing closed missions:", error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user