Simplify host overview and move enrollment into drawer

This commit is contained in:
2026-10-06 17:18:31 -04:00
parent a991198d69
commit ef290ae0ee
11 changed files with 310 additions and 61 deletions
+16
View File
@@ -0,0 +1,16 @@
import { db } from '../db/index.js';
import { listHosts } from './index.js';
import { presentHostPreparation } from './preparation.js';
import type { Host } from '../../hosts.js';
export interface HostOverview extends Host { serverCount: number }
/** Count assigned servers without loading their telemetry or historical placements. */
export function hostOverview(): HostOverview[] {
const hosts = listHosts();
const counts = new Map((db().prepare(`SELECT i.host_id, COUNT(*) AS count FROM native_instances i
JOIN servers s ON s.name = i.server
WHERE i.retired_at IS NULL AND s.destroyed_at IS NULL
GROUP BY i.host_id`).all() as { host_id: string; count: number }[]).map(row => [row.host_id, row.count]));
return hosts.map(host => ({ ...presentHostPreparation(host), serverCount: counts.get(host.id) ?? 0 }));
}