Add a power history to each game server
Each change a read of a Fragnet account sees, and each power signal sent from here with who sent it, is written down (180 days). A server's details show the share of the last 30 days it was on, starts and stops, a seven-day bar and the latest changes, with who asked for them. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9126200295
commit
a2b43bcd5d
14 files changed
+9773
-4
No files matched your search
@@ -20,7 +20,7 @@ process.env.HEALTH_STARTUP_GRACE_MS = "0";
|
||||
|
||||
const express = (await import("express")).default;
|
||||
const { db } = await import("../src/db/client.js");
|
||||
const { users, integrations, fragnetState, auditLog } = await import("../src/db/schema.js");
|
||||
const { users, integrations, fragnetState, fragnetPowerLog, auditLog } = await import("../src/db/schema.js");
|
||||
const { runMigrations } = await import("../src/db/migrate.js");
|
||||
const adapter = await import("../src/integrations/fragnet/adapter.js");
|
||||
const fn = await import("../src/services/fragnetSync.js");
|
||||
@@ -669,6 +669,14 @@ describe("the health pass, the page, the power signals and /metrics", () => {
|
||||
const [entry] = (await db.select().from(auditLog)).filter((e) => e.action === "restart_game_server");
|
||||
assert.deepEqual([entry.category, entry.targetType, entry.targetId], ["integration", "fragnet_server", "abcd1234"]);
|
||||
assert.match(entry.detail ?? "", /survival/);
|
||||
// and who asked, for the history
|
||||
const sent = (await db.select().from(fragnetPowerLog).where(eq(fragnetPowerLog.integrationId, fgId))).filter((r) => r.kind === "signal");
|
||||
assert.deepEqual(sent.map((r) => [r.serverId, r.detail, r.by]), [["abcd1234", "restart", "Olle"]]);
|
||||
const page = (await (await fetch(base, as("viewer"))).json()) as { accounts: { id: number; state: { servers: { id: string; power: { stats: { on: boolean; trackedSince: string } | null; timeline: { segments: unknown[] } | null; recent: { kind: string; by: string | null }[] } | null }[] } }[] };
|
||||
const power = page.accounts.find((a) => a.id === fgId)!.state.servers.find((x) => x.id === "abcd1234")!.power!;
|
||||
assert.equal(power.stats?.on, true);
|
||||
assert.ok((power.timeline?.segments.length ?? 0) >= 1);
|
||||
assert.deepEqual(power.recent.map((e) => [e.kind, e.by]), [["signal", "Olle"]]);
|
||||
});
|
||||
|
||||
test("only a server the last read found, and only a real signal, are accepted — nothing typed in the address reaches the panel", async () => {
|
||||
|
||||
Reference in new issue
Block a user