Merge branch 'litellm_alerts_pr2_final_validation' of /Users/mfkhalil/Code/litellm-activity-before into litellm_alerts_reconcile_03

This commit is contained in:
moe-berri 2026-11-07 11:55:58 +08:00
commit 73c4a52d4e
4 changed files with 14 additions and 2 deletions

View file

@ -1,3 +1,5 @@
SET LOCAL lock_timeout = '10s';
CREATE TABLE IF NOT EXISTS "LiteLLM_UsageAlertRule" (
"id" TEXT PRIMARY KEY, "scope_type" TEXT NOT NULL, "scope_id" TEXT,
"enabled" BOOLEAN NOT NULL DEFAULT true, "record" JSONB NOT NULL,

View file

@ -1,3 +1,5 @@
SET LOCAL lock_timeout = '10s';
CREATE TABLE IF NOT EXISTS "LiteLLM_Issue" (
"id" TEXT NOT NULL,
"cohort_key" TEXT NOT NULL,

View file

@ -529,7 +529,7 @@ class IssuesRepository:
"""WITH changed AS (
UPDATE "LiteLLM_Issue" SET active=false,
status=CASE WHEN status='open' THEN 'resolved' ELSE status END,updated_at=CURRENT_TIMESTAMP
WHERE id=ANY($1::text[]) AND kind='performance' AND active AND last_seen<=$2::timestamp(3)
WHERE id=ANY($1::text[]) AND kind='performance' AND active AND last_seen<$2::timestamp(3)
RETURNING id
) SELECT count(*)::int AS count FROM changed""",
list(ids),

View file

@ -1067,7 +1067,15 @@ async def test_provider_recovery_pages_saved_cohorts_and_rejects_stale_observati
assert first[0].id == inputs[0].id and second[0].id == inputs[1].id
assert await store.set_status(inputs[0].id, "dismissed", "open") is not None
assert await store.recover_issue_ids((inputs[0].id,), template.observed_at - timedelta(seconds=1)) == 0
assert await store.recover_issue_ids((inputs[0].id, inputs[1].id), template.observed_at) == 2
assert await store.recover_issue_ids((inputs[0].id, inputs[1].id), template.observed_at) == 0, (
"A recovery at the last observed timestamp must not close the alert"
)
assert (
await store.recover_issue_ids(
(inputs[0].id, inputs[1].id), template.observed_at + timedelta(milliseconds=1)
)
== 2
)
dismissed: Final = await store.get_issue(inputs[0].id)
resolved: Final = await store.get_issue(inputs[1].id)
assert dismissed is not None and not dismissed.active and dismissed.status == "dismissed"