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:
@@ -43,7 +43,7 @@ export async function runAction(machineId: string, action: ActionType): Promise<
|
|||||||
outputHub.publish(machineId, c);
|
outputHub.publish(machineId, c);
|
||||||
});
|
});
|
||||||
raw = res.stdout;
|
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";
|
status = "error";
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// server/services/refresh.ts
|
// server/services/refresh.ts
|
||||||
import { randomUUID } from "node:crypto";
|
import { randomUUID } from "node:crypto";
|
||||||
import { eq } from "drizzle-orm";
|
import { eq, desc } from "drizzle-orm";
|
||||||
import { db, schema } from "../db/client.js";
|
import { db, schema } from "../db/client.js";
|
||||||
import { getMachineRow, getCreds } from "./machines.js";
|
import { getMachineRow, getCreds } from "./machines.js";
|
||||||
import { renderTemplate } from "../templates/render.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 {
|
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;
|
return row ? (JSON.parse(row.payloadJson) as UpdateSnapshot) : null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user