Show running instances on host pages

This commit is contained in:
2026-10-05 13:56:37 -04:00
parent a6c40cde9b
commit a142f06c77
4 changed files with 87 additions and 3 deletions
+15
View File
@@ -0,0 +1,15 @@
import type { ServerObservation } from '../../server-observation.js';
import { db } from '../db/index.js';
import type { ServerRow } from '../fleet/servers.js';
import { observationReader } from '../fleet/status.js';
/** Current instances remain visible when their host or game stops reporting. */
export function hostInstances(hostId: string): ServerObservation[] {
const servers = db().prepare(`SELECT s.* FROM servers s
JOIN native_instances i ON i.server = s.name
WHERE i.host_id = ? AND i.retired_at IS NULL AND s.destroyed_at IS NULL
ORDER BY s.name`).all(hostId) as ServerRow[];
if (!servers.length) return [];
const observe = observationReader();
return servers.map(observe);
}