summaryrefslogtreecommitdiff
path: root/src/services/ping.rs
diff options
context:
space:
mode:
authorFxQnLr <[email protected]>2024-03-05 13:16:18 +0100
committerGitHub <[email protected]>2024-03-05 13:16:18 +0100
commit8dca7e83519b6c3531653cdedf60b2a14e1035b7 (patch)
tree0180a452dd354b067470618e6dbdc330649287cb /src/services/ping.rs
parentf0dc13f907a72ffef44f89b5e197567db129b020 (diff)
parent85c63c2ca8448428e2db93cb9d4f284a4e314ed7 (diff)
downloadwebol-8dca7e83519b6c3531653cdedf60b2a14e1035b7.tar
webol-8dca7e83519b6c3531653cdedf60b2a14e1035b7.tar.gz
webol-8dca7e83519b6c3531653cdedf60b2a14e1035b7.zip
Merge pull request #22 from FxQnLr/0.3.3
0.3.3
Diffstat (limited to 'src/services/ping.rs')
-rw-r--r--src/services/ping.rs31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/services/ping.rs b/src/services/ping.rs
index 9191f86..8cf6072 100644
--- a/src/services/ping.rs
+++ b/src/services/ping.rs
@@ -49,22 +49,27 @@ pub async fn spawn(
49 }; 49 };
50 } 50 }
51 51
52 trace!(?msg);
53
52 let msg = msg.expect("fatal error"); 54 let msg = msg.expect("fatal error");
53 55
54 let _ = tx.send(msg.clone()); 56 let _ = tx.send(msg.clone());
55 if let BroadcastCommands::Success = msg.command { 57 if msg.command == BroadcastCommands::Success {
56 sqlx::query!( 58 if timer.elapsed().whole_seconds() > config.pingthreshold {
57 r#" 59 sqlx::query!(
58 UPDATE devices 60 r#"
59 SET times = array_append(times, $1) 61 UPDATE devices
60 WHERE id = $2; 62 SET times = array_append(times, $1)
61 "#, 63 WHERE id = $2;
62 timer.elapsed().whole_seconds(), 64 "#,
63 device.id 65 timer.elapsed().whole_seconds(),
64 ) 66 device.id
65 .execute(db) 67 )
66 .await 68 .execute(db)
67 .unwrap(); 69 .await
70 .unwrap();
71 }
72
68 ping_map.insert( 73 ping_map.insert(
69 uuid.clone(), 74 uuid.clone(),
70 Value { 75 Value {