Skip to content

Commit e64afea

Browse files
authored
Add loud alert for triage retryables expiring within 3 days (#58)
1 parent f475dc3 commit e64afea

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

packages/retryable-monitor/handlers/notion/alertUntriagedRetraybles.ts

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,31 @@ export const alertUntriagedNotionRetryables = async () => {
4545
})
4646

4747
for (const page of response.results) {
48-
const props = (page as any).properties
49-
const timeoutRaw = props?.timeoutTimestamp?.date?.start
50-
const timeoutStr = formatDate(timeoutRaw)
51-
const retryableUrl =
52-
props?.ChildTx?.title?.[0]?.text?.content || '(unknown)'
53-
const decision = props?.Decision?.select?.name || '(unknown)'
48+
const props = (page as any).properties
49+
const timeoutRaw = props?.timeoutTimestamp?.date?.start
50+
const timeoutStr = formatDate(timeoutRaw)
51+
const retryableUrl = props?.ChildTx?.title?.[0]?.text?.content || '(unknown)'
52+
const decision = props?.Decision?.select?.name || '(unknown)'
5453

55-
let message = ''
54+
const expiryTime = timeoutRaw ? new Date(timeoutRaw).getTime() : Infinity
55+
const now = Date.now()
56+
const hoursLeft = (expiryTime - now) / (1000 * 60 * 60)
5657

57-
if (decision === 'Triage') {
58-
message = `⚠️ Retryable ticket needs triage:\n• Retryable: ${retryableUrl}\n• Timeout: ${timeoutStr}\n→ Please review and decide whether to redeem or ignore.`
59-
} else if (decision === 'Should Redeem') {
60-
if (!isNearExpiry(timeoutRaw)) continue // Skip if not near expiry
61-
message = `🚨 Retryable marked for redemption and nearing expiry:\n• Retryable: ${retryableUrl}\n• Timeout: ${timeoutStr}\n→ Check why it hasn't been executed.`
62-
} else {
63-
continue // skip unexpected decisions
64-
}
58+
let message = ''
6559

66-
await postSlackMessage({ message })
67-
}
60+
if (decision === 'Triage') {
61+
if (hoursLeft <= 72) {
62+
message = `🚨🚨 Retryable ticket needs **IMMEDIATE** triage (expires soon!):\n• Retryable: ${retryableUrl}\n• Timeout: ${timeoutStr}\n→ Please triage urgently.`
63+
} else {
64+
message = `⚠️ Retryable ticket needs triage:\n• Retryable: ${retryableUrl}\n• Timeout: ${timeoutStr}\n→ Please review and decide whether to redeem or ignore.`
65+
}
66+
} else if (decision === 'Should Redeem') {
67+
if (!isNearExpiry(timeoutRaw)) continue // Skip if not near expiry
68+
message = `🚨 Retryable marked for redemption and nearing expiry:\n• Retryable: ${retryableUrl}\n• Timeout: ${timeoutStr}\n→ Check why it hasn't been executed.`
69+
} else {
70+
continue // skip unexpected decisions
71+
}
6872

73+
await postSlackMessage({ message })
74+
}
6975
}

0 commit comments

Comments
 (0)