This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { db } from '../db/index.js';
|
||||
import type { CapacityHistory, CapacityQuery, CapacityRange } from '../../capacity.js';
|
||||
import type { HostMode } from '../../hosts.js';
|
||||
import { readTemperatureHistory } from './temperatures.js';
|
||||
|
||||
const windows: Record<CapacityRange, { duration: number; bucketMs: number }> = {
|
||||
@@ -16,13 +17,14 @@ export function readCapacityHistory(query: CapacityQuery, now = Date.now()): Cap
|
||||
const count = duration / bucketMs;
|
||||
const hosts = handle
|
||||
.prepare(
|
||||
`SELECT id,name,created_at FROM ec_hosts
|
||||
`SELECT id,name,created_at,mode FROM ec_hosts
|
||||
WHERE deleted_at IS NULL ${query.hostId ? 'AND id=?' : ''} ORDER BY id`
|
||||
)
|
||||
.all(...(query.hostId ? [query.hostId] : [])) as {
|
||||
id: string;
|
||||
name: string;
|
||||
created_at: string;
|
||||
mode: HostMode;
|
||||
}[];
|
||||
// The primary key bounds each host scan to the selected interval. Aggregate
|
||||
// before crossing the worker boundary; do not return raw heartbeat rows.
|
||||
@@ -44,6 +46,9 @@ export function readCapacityHistory(query: CapacityQuery, now = Date.now()): Cap
|
||||
expectedHosts: 0
|
||||
}));
|
||||
for (const host of hosts) {
|
||||
// Current mode determines available capacity; keep inactive hosts in
|
||||
// the separate temperature history for diagnostics.
|
||||
if (host.mode !== 'active') continue;
|
||||
const createdAt = Date.parse(host.created_at);
|
||||
for (const point of points) {
|
||||
if (createdAt <= Math.min(now, point.at + bucketMs)) point.expectedHosts++;
|
||||
|
||||
@@ -234,10 +234,11 @@
|
||||
<details class="about">
|
||||
<summary>About this chart</summary>
|
||||
<p class="note">
|
||||
Available host resources after the operating-system reserve, averaged per period. Gaps
|
||||
mean reporting is incomplete. Reporting-host coverage is shown for each selected period.
|
||||
This history includes all workloads on the selected hosts; it does not reconstruct
|
||||
historical launch eligibility, queued jobs, or port availability.
|
||||
Available resources from currently active hosts after the operating-system reserve,
|
||||
averaged per period. Disabled and draining hosts are excluded. Gaps mean reporting is
|
||||
incomplete. Reporting-host coverage is shown for each selected period. This history
|
||||
includes all workloads on the selected hosts; it does not reconstruct historical launch
|
||||
eligibility, queued jobs, or port availability.
|
||||
</p>
|
||||
<details bind:open={tableOpen}>
|
||||
<summary>View history data · {$timeZone.replaceAll('_', ' ')}</summary>
|
||||
|
||||
Reference in New Issue
Block a user