grouped notifications into a single notification instead of one per task

This commit is contained in:
2026-05-07 16:49:14 -05:00
parent 6658043fcc
commit 1472501a1f
+29 -2
View File
@@ -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
}