Count items in database as much as possible (#344)
* Count items in database as much as possible * Fix the tests * Remove two useless queries * Run pragma directive before each sqlite connection * Pragma for tests too * Remove debug messages
This commit is contained in:
@@ -48,6 +48,14 @@ impl Notification {
|
||||
.expect("Notification::find_for_user: notification loading error")
|
||||
}
|
||||
|
||||
pub fn count_for_user(conn: &Connection, user: &User) -> i64 {
|
||||
notifications::table
|
||||
.filter(notifications::user_id.eq(user.id))
|
||||
.count()
|
||||
.get_result(conn)
|
||||
.expect("Notification::count_for_user: count loading error")
|
||||
}
|
||||
|
||||
pub fn page_for_user(
|
||||
conn: &Connection,
|
||||
user: &User,
|
||||
|
||||
Reference in New Issue
Block a user