only-last-30-days-notifications #332

Merged
philipp merged 3 commits from only-last-30-days-notifications into main 2024-03-31 13:09:26 +02:00
Showing only changes of commit ef4e6f57d9 - Show all commits

View File

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