| 477 | } |
| 478 | |
| 479 | pub async fn update_device(d: FuotaDeploymentDevice) -> Result<FuotaDeploymentDevice, Error> { |
| 480 | let d: FuotaDeploymentDevice = diesel::update( |
| 481 | fuota_deployment_device::dsl::fuota_deployment_device |
| 482 | .find((&d.fuota_deployment_id, &d.dev_eui)), |
| 483 | ) |
| 484 | .set(( |
| 485 | fuota_deployment_device::completed_at.eq(&d.completed_at), |
| 486 | fuota_deployment_device::mc_group_setup_completed_at.eq(&d.mc_group_setup_completed_at), |
| 487 | fuota_deployment_device::mc_session_completed_at.eq(&d.mc_session_completed_at), |
| 488 | fuota_deployment_device::frag_session_setup_completed_at |
| 489 | .eq(&d.frag_session_setup_completed_at), |
| 490 | fuota_deployment_device::frag_status_completed_at.eq(&d.frag_status_completed_at), |
| 491 | fuota_deployment_device::error_msg.eq(&d.error_msg), |
| 492 | )) |
| 493 | .get_result(&mut get_async_db_conn().await?) |
| 494 | .await |
| 495 | .map_err(|e| Error::from_diesel(e, d.dev_eui.to_string()))?; |
| 496 | |
| 497 | info!(fuota_deployment_id = %d.fuota_deployment_id, dev_eui = %d.dev_eui, "FUOTA deployment device updated"); |
| 498 | Ok(d) |
| 499 | } |
| 500 | |
| 501 | pub async fn remove_devices(fuota_deployment_id: Uuid, dev_euis: Vec<EUI64>) -> Result<(), Error> { |
| 502 | diesel::delete( |