only show read notifications for last 30 days
This commit is contained in:
parent
974b4aeb48
commit
ef4e6f57d9
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user