We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 335298b commit b2bee2eCopy full SHA for b2bee2e
policylens/apps/claims/sla.py
@@ -79,4 +79,21 @@ def ensure_sla_clock_exists(*, claim: Claim) -> SlaClock:
79
claim=claim,
80
started_at=anchor,
81
due_at=due_at,
82
- )
+ )
83
+
84
85
+def find_breached_clocks(*, now) -> Iterable[SlaClock]:
86
+ """Return clocks that are currently breached and not yet marked.
87
88
+ Args:
89
+ now: Current time.
90
91
+ Returns:
92
+ Iterable of SlaClock objects.
93
+ """
94
+ return (
95
+ SlaClock.objects.select_related("claim")
96
+ .filter(breached_at__isnull=True, due_at__isnull=False, due_at__lt=now)
97
+ .exclude(claim__status=Claim.Status.DECIDED)
98
+ .order_by("due_at")
99
0 commit comments