From 1472501a1f552b55513d11cbd47dc2df39a78662 Mon Sep 17 00:00:00 2001 From: Kelly Thomas Reardon Date: Thu, 7 May 2026 16:49:14 -0500 Subject: [PATCH] grouped notifications into a single notification instead of one per task --- Start-DoneTickNotifier.ps1 | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/Start-DoneTickNotifier.ps1 b/Start-DoneTickNotifier.ps1 index b14584f..b01f14d 100644 --- a/Start-DoneTickNotifier.ps1 +++ b/Start-DoneTickNotifier.ps1 @@ -53,6 +53,9 @@ function Get-Chores $today = (Get-Date "23:59:59") $chores = Get-Chores +$overdueTasks = @() +$todaysTasks = @() + foreach($chore in $chores) { if ($chore.nextDueDate) @@ -61,16 +64,40 @@ foreach($chore in $chores) if (($dueDate - $today).Days -lt 0) #OVERDUE { write-host "$($chore.name) $dueDate is overdue!" - Send-Notification -title "OVERDUE TASK" -content "$($chore.Name) is overdue! Due date is $($chore.nextDueDate)" + $overdueTasks += $chore } elseif (($dueDate - $today) -lt 1) #due today { write-host "$($chore.name) $dueDate is due today!" - Send-Notification -title "TASK DUE TODAY" -content "$($chore.Name) is due today!" + $todaysTasks += $chore + # Send-Notification -title "TASK DUE TODAY" -content "$($chore.Name) is due today!" } else { write-host "$($chore.name) $dueDate is due in the future" } } + +} + +if ($overdueTasks.Count -ne 0) +{ + Write-Host "Sending a notification for $($overdueTasks.Count) overdue tasks" + $content = "The following tasks are overdue!\n" + foreach($overdueTask in $overdueTasks) + { + $content += "$($overdueTask.Name) was due $($overdueTask.nextDueDate)\n" + } + Send-Notification -title "OVERDUE TASKS" -content $content +} + +if ($todaysTasks.Count -ne 0) +{ + Write-Host "Sending a notification for $($todaysTasks.Count) tasks due today" + $content = "The following tasks are due today!\n" + foreach($task in $todaysTasks) + { + $content += "$($task.Name) is due $($task.nextDueDate)\n" + } + Send-Notification -title "TODAY'S TASKS" -content $content } \ No newline at end of file