Add notifications for review tasks

This commit is contained in:
Eli Ribble 2026-03-19 16:01:44 +00:00
parent 786a6c16a3
commit 954a4330ee
No known key found for this signature in database
2 changed files with 19 additions and 1 deletions

View file

@ -84,6 +84,16 @@
>
<div class="menu-icon">{{ template "review.svg" }}</div>
<span class="menu-text ms-2">Review</span>
<span
x-show="notification_counts.review > 0"
x-cloak
class="position-absolute translate-middle badge rounded-pill bg-primary"
>
<span
x-text="notification_counts.reviwe > 99 ? '99+' : notification_counts.review"
></span>
<span class="visually-hidden">unread notifications</span>
</span>
</a>
</li>
<li>

View file

@ -30,6 +30,7 @@ type Notification struct {
type UserNotificationCounts struct {
Communications uint `json:"communication"`
Home uint `json:"home"`
Review uint `json:"review"`
}
// Clear all notifications for a given user with the given path
@ -117,10 +118,17 @@ func NotificationCountsForUser(ctx context.Context, u User) (*UserNotificationCo
if err != nil {
return nil, fmt.Errorf("Failed to get nuisance notification count: %w", err)
}
log.Debug().Int64("reports", count_reports).Int64("home", count_home).Int("user", u.ID).Msg("calculated notification counts")
count_review, err := u.Organization.model.ReviewTasks(
models.SelectWhere.ReviewTasks.Reviewed.IsNull(),
).Count(ctx, db.PGInstance.BobDB)
if err != nil {
return nil, fmt.Errorf("Failed to get review notification count: %w", err)
}
log.Debug().Int64("reports", count_reports).Int64("home", count_home).Int64("review", count_review).Int("user", u.ID).Msg("calculated notification counts")
return &UserNotificationCounts{
Communications: uint(count_reports),
Home: uint(count_home),
Review: uint(count_review),
}, nil
}