Show running instances on host pages
This commit is contained in:
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user