65 lines
2.1 KiB
Python
65 lines
2.1 KiB
Python
from ..models import NormalizedState, TriageRecommendation, TriageResult, Snapshot
|
|
|
|
|
|
def triage_snapshot(snapshot: Snapshot) -> TriageResult:
|
|
recommendations = []
|
|
root_cause = "unknown"
|
|
summary = "No clear blocker detected yet."
|
|
confidence = 0.2
|
|
|
|
if snapshot.state == NormalizedState.requested:
|
|
root_cause = "approval"
|
|
summary = "The request is waiting for approval in Jellyseerr."
|
|
recommendations.append(
|
|
TriageRecommendation(
|
|
action_id="wait_for_approval",
|
|
title="Ask an admin to approve the request",
|
|
reason="Jellyseerr has not marked this request as approved.",
|
|
risk="low",
|
|
)
|
|
)
|
|
confidence = 0.6
|
|
|
|
if snapshot.state == NormalizedState.needs_add:
|
|
root_cause = "not_added"
|
|
summary = "The request is approved but not added to Sonarr/Radarr yet."
|
|
recommendations.append(
|
|
TriageRecommendation(
|
|
action_id="readd_to_arr",
|
|
title="Add it to the library queue",
|
|
reason="Sonarr/Radarr has not created the entry for this request.",
|
|
risk="medium",
|
|
)
|
|
)
|
|
confidence = 0.7
|
|
|
|
if snapshot.state == NormalizedState.added_to_arr:
|
|
root_cause = "search"
|
|
summary = "The item is in Sonarr/Radarr but has not been downloaded yet."
|
|
recommendations.append(
|
|
TriageRecommendation(
|
|
action_id="search",
|
|
title="Re-run search",
|
|
reason="A fresh search can locate new releases.",
|
|
risk="low",
|
|
)
|
|
)
|
|
confidence = 0.55
|
|
|
|
if not recommendations:
|
|
recommendations.append(
|
|
TriageRecommendation(
|
|
action_id="diagnostics",
|
|
title="Generate diagnostics bundle",
|
|
reason="Collect service status and recent errors for review.",
|
|
risk="low",
|
|
)
|
|
)
|
|
|
|
return TriageResult(
|
|
summary=summary,
|
|
confidence=confidence,
|
|
root_cause=root_cause,
|
|
recommendations=recommendations,
|
|
)
|