only show read notifications for last 30 days
All checks were successful
CI/CD Pipeline / test (push) Successful in 10m36s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped

This commit is contained in:
philipp 2024-03-31 13:07:40 +02:00
parent 974b4aeb48
commit ef4e6f57d9

View File

@ -58,7 +58,16 @@ impl Notification {
pub async fn for_user(db: &SqlitePool, user: &User) -> Vec<Self> { pub async fn for_user(db: &SqlitePool, user: &User) -> Vec<Self> {
sqlx::query_as!( sqlx::query_as!(
Self, 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 user.id
) )
.fetch_all(db) .fetch_all(db)