11 lines
563 B
TypeScript
11 lines
563 B
TypeScript
import { error } from '@sveltejs/kit';
|
|
import { capacityHistoryReport } from '../reports/index.js';
|
|
import { readCapacityCurrent } from './capacity-overview.js';
|
|
import type { CapacityData, CapacityQuery } from '../../capacity.js';
|
|
|
|
export async function capacityPage(query: CapacityQuery): Promise<CapacityData> {
|
|
const current = await readCapacityCurrent(query);
|
|
if (query.hostId && !current.hostOptions.some(host => host.id === query.hostId)) error(404, 'Host not found.');
|
|
return { query, current, history: await capacityHistoryReport(query) };
|
|
}
|