mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-15 23:12:04 +00:00
fix(status): expose background failures
This commit is contained in:
1 parent
a689329e79
commit
8ece6f39cc
31 files changed
+854
-44
No files matched your search
@@ -50,6 +50,8 @@ export interface IntegrationStatusViewModel {
|
||||
reauth_required: number;
|
||||
persistent: number;
|
||||
} | null;
|
||||
/** Client-side copy of the envelope threshold, attached by `pickStatus`. */
|
||||
failureThreshold?: number;
|
||||
configured?: boolean;
|
||||
connected?: boolean;
|
||||
connectedAt?: string | null;
|
||||
@@ -110,7 +112,12 @@ export function pickStatus(
|
||||
envelope: IntegrationStatusEnvelope | undefined,
|
||||
integration: IntegrationKey,
|
||||
): IntegrationStatusViewModel | undefined {
|
||||
return envelope?.integrations.find((i) => i.integration === integration);
|
||||
const status = envelope?.integrations.find(
|
||||
(entry) => entry.integration === integration,
|
||||
);
|
||||
return status
|
||||
? { ...status, failureThreshold: envelope?.threshold }
|
||||
: undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -158,6 +165,36 @@ export function pillStateFor(
|
||||
return pillStateForVerdict(status?.syncHealth?.verdict);
|
||||
}
|
||||
|
||||
export interface IntegrationPillFailureProps {
|
||||
failureCount?: number;
|
||||
failureThreshold?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pair the largest per-kind streak with the server-owned alert threshold. The
|
||||
* alert ladder uses the same maximum, so the ratio cannot disagree with when a
|
||||
* notification becomes eligible.
|
||||
*/
|
||||
export function pillFailurePropsFor(
|
||||
status:
|
||||
| Pick<
|
||||
IntegrationStatusViewModel,
|
||||
"consecutiveFailuresByKind" | "failureThreshold"
|
||||
>
|
||||
| undefined,
|
||||
): IntegrationPillFailureProps {
|
||||
const buckets = status?.consecutiveFailuresByKind;
|
||||
const failureThreshold = status?.failureThreshold;
|
||||
if (!buckets || failureThreshold === undefined) return {};
|
||||
|
||||
const failureCount = Math.max(
|
||||
buckets.transient,
|
||||
buckets.reauth_required,
|
||||
buckets.persistent,
|
||||
);
|
||||
return failureCount > 0 ? { failureCount, failureThreshold } : {};
|
||||
}
|
||||
|
||||
/**
|
||||
* The timestamp the pill shows inline. `connected` reads the last success (a
|
||||
* connection row's own `lastSyncedAt` wins when it is newer, which is what
|
||||
|
||||
Reference in new issue
Block a user