Mark user as updated after fetching

This commit is contained in:
Felix Ableitner 2020-12-01 18:45:46 +01:00
parent 6cf4e39406
commit 89f9ecb634
2 changed files with 12 additions and 2 deletions

View file

@ -258,8 +258,12 @@ pub(crate) async fn get_or_fetch_and_upsert_user(
recursion_counter,
)
.await?;
// TODO: do we need to set this? would need a separate db call
//uf.last_refreshed_at = Some(naive_now());
let user_id = user.id;
blocking(context.pool(), move |conn| {
User_::mark_as_updated(conn, user_id)
})
.await??;
Ok(user)
}

View file

@ -188,6 +188,12 @@ impl User_ {
.get_result::<Self>(conn)
}
pub fn mark_as_updated(conn: &PgConnection, user_id: i32) -> Result<User_, Error> {
diesel::update(user_.find(user_id))
.set((updated.eq(naive_now()),))
.get_result::<Self>(conn)
}
pub fn delete_account(conn: &PgConnection, user_id: i32) -> Result<User_, Error> {
diesel::update(user_.find(user_id))
.set((