Add Prettier and ESLint tooling (Refs #77)
This commit is contained in:
@@ -2,17 +2,34 @@ import { db } from '../db/index.js';
|
||||
|
||||
/** Maintenance must leave pending lifecycle work and retained recovery to Provisioning. */
|
||||
export function hasActiveProvisioning(server: string, exceptOperationId = ''): boolean {
|
||||
return !!db().prepare(`SELECT 1 FROM server_deployments
|
||||
return (
|
||||
!!db()
|
||||
.prepare(
|
||||
`SELECT 1 FROM server_deployments
|
||||
WHERE server = ? AND server_deleted_at IS NULL AND id != ?
|
||||
AND state IN ('queued', 'waiting', 'running', 'awaiting-health') LIMIT 1`).get(server, exceptOperationId)
|
||||
|| !!db().prepare(`SELECT 1 FROM restart_rollout WHERE server = ? AND healthy_at IS NULL
|
||||
AND (operation_id IS NULL OR operation_id != ?)`).get(server, exceptOperationId);
|
||||
AND state IN ('queued', 'waiting', 'running', 'awaiting-health') LIMIT 1`
|
||||
)
|
||||
.get(server, exceptOperationId) ||
|
||||
!!db()
|
||||
.prepare(
|
||||
`SELECT 1 FROM restart_rollout WHERE server = ? AND healthy_at IS NULL
|
||||
AND (operation_id IS NULL OR operation_id != ?)`
|
||||
)
|
||||
.get(server, exceptOperationId)
|
||||
);
|
||||
}
|
||||
|
||||
/** Only the latest lifecycle operation can describe the current server. */
|
||||
export function isProvisioning(server: string): boolean {
|
||||
const operation = db().prepare(`SELECT action, state FROM server_deployments
|
||||
WHERE server = ? AND server_deleted_at IS NULL ORDER BY rowid DESC LIMIT 1`).get(server) as
|
||||
{ action: string; state: string } | undefined;
|
||||
return !!operation && ['create', 'rebuild', 'start'].includes(operation.action) && ['queued', 'running', 'awaiting-health'].includes(operation.state);
|
||||
const operation = db()
|
||||
.prepare(
|
||||
`SELECT action, state FROM server_deployments
|
||||
WHERE server = ? AND server_deleted_at IS NULL ORDER BY rowid DESC LIMIT 1`
|
||||
)
|
||||
.get(server) as { action: string; state: string } | undefined;
|
||||
return (
|
||||
!!operation &&
|
||||
['create', 'rebuild', 'start'].includes(operation.action) &&
|
||||
['queued', 'running', 'awaiting-health'].includes(operation.state)
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user