Merge pull request 'only-last-30-days-notifications' (#331) from only-last-30-days-notifications into staging
All checks were successful
CI/CD Pipeline / test (push) Successful in 11m17s
CI/CD Pipeline / deploy-staging (push) Successful in 5m13s
CI/CD Pipeline / deploy-main (push) Has been skipped

Reviewed-on: #331
This commit is contained in:
2024-04-01 22:38:37 +02:00
2 changed files with 504 additions and 1 deletions

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)