From ef4e6f57d97ebf20239a669a970d7ce2c5524e32 Mon Sep 17 00:00:00 2001 From: philipp Date: Sun, 31 Mar 2024 13:07:40 +0200 Subject: [PATCH] only show read notifications for last 30 days --- src/model/notification.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/model/notification.rs b/src/model/notification.rs index 3268e6d..2a661cf 100644 --- a/src/model/notification.rs +++ b/src/model/notification.rs @@ -58,7 +58,16 @@ impl Notification { pub async fn for_user(db: &SqlitePool, user: &User) -> Vec { sqlx::query_as!( Self, - "SELECT * FROM notification WHERE user_id = ? ORDER BY created_at DESC", + " +SELECT * FROM notification +WHERE + user_id = ? + AND ( + read_at IS NULL + OR read_at >= datetime('now', '-30 days') + ) +ORDER BY read_at DESC, created_at DESC; + ", user.id ) .fetch_all(db)