fix: ORDER BY sur getLatestSnapshot + lisibilité condition EXIT

Suite revue batch D.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-05 04:10:56 +02:00
parent 1fb93873ac
commit f5f361a349
2 changed files with 8 additions and 3 deletions
+1 -1
View File
@@ -43,7 +43,7 @@ export async function runAction(machineId: string, action: ActionType): Promise<
outputHub.publish(machineId, c);
});
raw = res.stdout;
if (/===SU:EXIT=(\d+)===/.exec(raw)?.[1] && /===SU:EXIT=0===/.test(raw) === false) {
if (/===SU:EXIT=\d+===/.test(raw) && !/===SU:EXIT=0===/.test(raw)) {
status = "error";
}
} catch (err) {
+7 -2
View File
@@ -1,6 +1,6 @@
// server/services/refresh.ts
import { randomUUID } from "node:crypto";
import { eq } from "drizzle-orm";
import { eq, desc } from "drizzle-orm";
import { db, schema } from "../db/client.js";
import { getMachineRow, getCreds } from "./machines.js";
import { renderTemplate } from "../templates/render.js";
@@ -71,6 +71,11 @@ export async function refreshMachine(machineId: string): Promise<UpdateSnapshot>
}
export function getLatestSnapshot(machineId: string): UpdateSnapshot | null {
const row = db.select().from(schema.snapshots).where(eq(schema.snapshots.machineId, machineId)).all().at(-1);
const row = db
.select()
.from(schema.snapshots)
.where(eq(schema.snapshots.machineId, machineId))
.orderBy(desc(schema.snapshots.checkedAt))
.get();
return row ? (JSON.parse(row.payloadJson) as UpdateSnapshot) : null;
}