fix: fixed handling of new beacons
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user