Show latest active device as last active on admin page

This commit is contained in:
janost
2020-11-30 22:00:51 +01:00
parent 9824d94a1c
commit 1eb5495802
4 changed files with 25 additions and 0 deletions

View File

@@ -178,4 +178,15 @@ impl Device {
.from_db()
}}
}
pub fn find_latest_active_by_user(user_uuid: &str, conn: &DbConn) -> Option<Self> {
db_run! { conn: {
devices::table
.filter(devices::user_uuid.eq(user_uuid))
.order(devices::updated_at.desc())
.first::<DeviceDb>(conn)
.ok()
.from_db()
}}
}
}