Add pagination for notifications

And correctly close an <a> tag
This commit is contained in:
Bat
2018-07-25 15:33:54 +02:00
parent 18125ab398
commit 4b0aba62f3
4 changed files with 25 additions and 5 deletions
+9
View File
@@ -35,4 +35,13 @@ impl Notification {
.load::<Notification>(conn)
.expect("Couldn't load user notifications")
}
pub fn page_for_user(conn: &PgConnection, user: &User, (min, max): (i32, i32)) -> Vec<Notification> {
notifications::table.filter(notifications::user_id.eq(user.id))
.order_by(notifications::creation_date.desc())
.offset(min.into())
.limit((max - min).into())
.load::<Notification>(conn)
.expect("Couldn't load user notifications page")
}
}