feat(edge): day sheet digest push

Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
2026-09-28 13:50:31 +08:00
parent e0dd3f6368
commit 20e95ffe37
@@ -197,6 +197,33 @@ async function processBatch() {
data.navigate_to = '/announcements' data.navigate_to = '/announcements'
break break
} }
case 'day_sheet_digest': {
const { count, error: countErr } = await supabase
.from('programmer_day_sheets')
.select('id', { count: 'exact', head: true })
.eq('status', 'pending')
if (countErr) {
console.error('Failed to count pending day sheets', countErr)
throw countErr
}
const n = count ?? 0
if (n === 0) {
// No pending sheets; mark processed and skip sending
await supabase
.from('scheduled_notifications')
.update({ processed: true, processed_at: new Date().toISOString() })
.eq('id', rowId)
console.log('Day sheet digest: no pending sheets, skipped', rowId)
continue
}
title = 'Day sheets awaiting review'
body = `${n} day sheet${n === 1 ? ' is' : 's are'} awaiting your review.`
data.navigate_to = '/programmer-tasks?tab=approvals'
break
}
default: default:
title = 'Reminder' title = 'Reminder'
body = 'You have a pending notification.' body = 'You have a pending notification.'