put hit register into transaction
This commit is contained in:
parent
a2c466f5ac
commit
bc05fe87b3
|
@ -73,10 +73,15 @@ async fn register_hit(
|
|||
let key = format!("{now}{host}{slug}{salt}").into_bytes();
|
||||
let key = hex::encode(shasum(&key));
|
||||
|
||||
let tx = db.begin().await;
|
||||
|
||||
if let Ok(mut tx) = tx {
|
||||
sqlx::query!("insert into hits (page, hit_key) values (?, ?)", slug, key,)
|
||||
.execute(&db)
|
||||
.execute(&mut *tx)
|
||||
.await
|
||||
.unwrap_or_default();
|
||||
tx.commit().await.unwrap_or_default();
|
||||
}
|
||||
|
||||
"".to_string()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue