feat: adiciona informacoes de reinicio e melhora SLA global
All checks were successful
All checks were successful
- Agente Rust: captura LastBootTime, uptime e contagem de boots - Backend: extrai campos do extended (bootInfo, discos, RAM, etc) antes de salvar - Frontend /devices: exibe secao de ultimo reinicio - SLA global: adiciona campos de modo, threshold de alerta e status de pausa - Corrige acento em "destinatario" -> "destinatario" em automations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
d32b94c22d
commit
f39bd46c2b
7 changed files with 338 additions and 19 deletions
|
|
@ -9,6 +9,26 @@ function normalizeName(value: string) {
|
|||
return value.trim();
|
||||
}
|
||||
|
||||
function normalizeMode(value?: string): "business" | "calendar" {
|
||||
if (value === "business") return "business";
|
||||
return "calendar";
|
||||
}
|
||||
|
||||
function normalizeThreshold(value?: number): number {
|
||||
if (value === undefined || value === null) return 0.8;
|
||||
if (value < 0.1) return 0.1;
|
||||
if (value > 0.95) return 0.95;
|
||||
return value;
|
||||
}
|
||||
|
||||
const VALID_PAUSE_STATUSES = ["PAUSED", "PENDING", "AWAITING_ATTENDANCE"] as const;
|
||||
|
||||
function normalizePauseStatuses(statuses?: string[]): string[] {
|
||||
if (!statuses || statuses.length === 0) return ["PAUSED"];
|
||||
const filtered = statuses.filter((s) => VALID_PAUSE_STATUSES.includes(s as typeof VALID_PAUSE_STATUSES[number]));
|
||||
return filtered.length > 0 ? filtered : ["PAUSED"];
|
||||
}
|
||||
|
||||
type AnyCtx = QueryCtx | MutationCtx;
|
||||
|
||||
async function ensureUniqueName(ctx: AnyCtx, tenantId: string, name: string, excludeId?: Id<"slaPolicies">) {
|
||||
|
|
@ -35,7 +55,11 @@ export const list = query({
|
|||
name: policy.name,
|
||||
description: policy.description ?? "",
|
||||
timeToFirstResponse: policy.timeToFirstResponse ?? null,
|
||||
responseMode: policy.responseMode ?? "calendar",
|
||||
timeToResolution: policy.timeToResolution ?? null,
|
||||
solutionMode: policy.solutionMode ?? "calendar",
|
||||
alertThreshold: policy.alertThreshold ?? 0.8,
|
||||
pauseStatuses: policy.pauseStatuses ?? ["PAUSED"],
|
||||
}));
|
||||
},
|
||||
});
|
||||
|
|
@ -47,9 +71,14 @@ export const create = mutation({
|
|||
name: v.string(),
|
||||
description: v.optional(v.string()),
|
||||
timeToFirstResponse: v.optional(v.number()),
|
||||
responseMode: v.optional(v.string()),
|
||||
timeToResolution: v.optional(v.number()),
|
||||
solutionMode: v.optional(v.string()),
|
||||
alertThreshold: v.optional(v.number()),
|
||||
pauseStatuses: v.optional(v.array(v.string())),
|
||||
},
|
||||
handler: async (ctx, { tenantId, actorId, name, description, timeToFirstResponse, timeToResolution }) => {
|
||||
handler: async (ctx, args) => {
|
||||
const { tenantId, actorId, name, description, timeToFirstResponse, responseMode, timeToResolution, solutionMode, alertThreshold, pauseStatuses } = args;
|
||||
await requireAdmin(ctx, actorId, tenantId);
|
||||
const trimmed = normalizeName(name);
|
||||
if (trimmed.length < 2) {
|
||||
|
|
@ -68,7 +97,11 @@ export const create = mutation({
|
|||
name: trimmed,
|
||||
description,
|
||||
timeToFirstResponse,
|
||||
responseMode: normalizeMode(responseMode),
|
||||
timeToResolution,
|
||||
solutionMode: normalizeMode(solutionMode),
|
||||
alertThreshold: normalizeThreshold(alertThreshold),
|
||||
pauseStatuses: normalizePauseStatuses(pauseStatuses),
|
||||
});
|
||||
return id;
|
||||
},
|
||||
|
|
@ -82,9 +115,14 @@ export const update = mutation({
|
|||
name: v.string(),
|
||||
description: v.optional(v.string()),
|
||||
timeToFirstResponse: v.optional(v.number()),
|
||||
responseMode: v.optional(v.string()),
|
||||
timeToResolution: v.optional(v.number()),
|
||||
solutionMode: v.optional(v.string()),
|
||||
alertThreshold: v.optional(v.number()),
|
||||
pauseStatuses: v.optional(v.array(v.string())),
|
||||
},
|
||||
handler: async (ctx, { policyId, tenantId, actorId, name, description, timeToFirstResponse, timeToResolution }) => {
|
||||
handler: async (ctx, args) => {
|
||||
const { policyId, tenantId, actorId, name, description, timeToFirstResponse, responseMode, timeToResolution, solutionMode, alertThreshold, pauseStatuses } = args;
|
||||
await requireAdmin(ctx, actorId, tenantId);
|
||||
const policy = await ctx.db.get(policyId);
|
||||
if (!policy || policy.tenantId !== tenantId) {
|
||||
|
|
@ -106,7 +144,11 @@ export const update = mutation({
|
|||
name: trimmed,
|
||||
description,
|
||||
timeToFirstResponse,
|
||||
responseMode: normalizeMode(responseMode),
|
||||
timeToResolution,
|
||||
solutionMode: normalizeMode(solutionMode),
|
||||
alertThreshold: normalizeThreshold(alertThreshold),
|
||||
pauseStatuses: normalizePauseStatuses(pauseStatuses),
|
||||
});
|
||||
},
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue