diff --git a/src/main.rs b/src/main.rs index f2d312a..8760dd7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -73,10 +73,15 @@ async fn register_hit( let key = format!("{now}{host}{slug}{salt}").into_bytes(); let key = hex::encode(shasum(&key)); - sqlx::query!("insert into hits (page, hit_key) values (?, ?)", slug, key,) - .execute(&db) - .await - .unwrap_or_default(); + let tx = db.begin().await; + + if let Ok(mut tx) = tx { + sqlx::query!("insert into hits (page, hit_key) values (?, ?)", slug, key,) + .execute(&mut *tx) + .await + .unwrap_or_default(); + tx.commit().await.unwrap_or_default(); + } "".to_string() }