Adds error handling for hit inserting

This commit is contained in:
2025-10-06 16:43:38 +02:00
parent a2b4c027df
commit 1d9c9a25d6

View File

@@ -63,8 +63,7 @@ pub async fn get(id: &str, meta: ReqMeta, state: &State<AppState>) -> Result<Nam
return Err(Status::NotFound);
}
// TODO: handle possible error
let _ = diesel::insert_into(hits::table)
let result = diesel::insert_into(hits::table)
.values(&Hit {
id: Uuid::new_v4(),
tracker_id: id,
@@ -74,6 +73,9 @@ pub async fn get(id: &str, meta: ReqMeta, state: &State<AppState>) -> Result<Nam
created_at: Utc::now().naive_utc(),
})
.execute(&mut *db);
if result.is_err() {
error!("Failed to insert hit: {:?}", result);
}
}
NamedFile::open(Path::new(state.image_path.as_str()))