Add NodeInfo endpoints (fixes #11)

This commit is contained in:
Bat
2018-06-10 20:33:42 +01:00
parent 7fd152e270
commit d8bd9dbfca
6 changed files with 72 additions and 4 deletions
+7
View File
@@ -119,6 +119,13 @@ impl User {
.into_iter().nth(0)
}
pub fn count_local(conn: &PgConnection) -> usize {
users::table.filter(users::instance_id.eq(Instance::local_id(conn)))
.load::<User>(conn)
.expect("Couldn't load local users")
.len()
}
pub fn find_by_email(conn: &PgConnection, email: String) -> Option<User> {
users::table.filter(users::email.eq(email))
.limit(1)