fix: fixed handling of new beacons

This commit is contained in:
Andrew Rioux
2025-02-23 02:00:38 -05:00
parent e0af4ad291
commit ceb4aa808e
3 changed files with 9 additions and 6 deletions

View File

@@ -94,15 +94,18 @@ pub async fn handle_checkin(
.fetch_optional(&state.db)
.await?;
if let Some(category_id) = template_category.map(|r| r.default_category) {
sqlx::query!(
if let Some(category_id) = template_category.map(|r| r.default_category).flatten() {
if let Err(e) = sqlx::query!(
"INSERT INTO beacon_category_assignment (category_id, beacon_id)
VALUES (?, ?)",
category_id,
reg.beacon_id
)
.execute(&state.db)
.await?;
.await {
tracing::warn!("Could not assign beacon to default category: {e:?}");
return Err(e.into());
};
}
sqlx::query!(
@@ -138,6 +141,7 @@ pub async fn handle_checkin(
}
};
tracing::debug!("Here 5");
let now = chrono::Utc::now();
sqlx::query!(
r"INSERT INTO beacon_checkin (beacon_id, checkin_date) VALUES (?, ?)"r,