aboutsummaryrefslogtreecommitdiff
path: root/src/services/ping.rs
diff options
context:
space:
mode:
authorFxQnLr <[email protected]>2023-11-16 14:17:03 +0100
committerFxQnLr <[email protected]>2023-11-16 14:17:03 +0100
commit075b0bdc47713e303f9954556fa4b4bb472b441a (patch)
treeb7ee38cc5a247151d99f0fbb75a529e5b07718e9 /src/services/ping.rs
parenta197f4721d3b6e79c73f16c8db69ae9f3154acec (diff)
downloadwebol-075b0bdc47713e303f9954556fa4b4bb472b441a.tar
webol-075b0bdc47713e303f9954556fa4b4bb472b441a.tar.gz
webol-075b0bdc47713e303f9954556fa4b4bb472b441a.zip
check if already runs and bug fix
Diffstat (limited to 'src/services/ping.rs')
-rw-r--r--src/services/ping.rs14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/services/ping.rs b/src/services/ping.rs
index 2bff61f..c3bdced 100644
--- a/src/services/ping.rs
+++ b/src/services/ping.rs
@@ -104,15 +104,13 @@ pub async fn status_websocket(mut socket: WebSocket, state: Arc<AppState>) {
104async fn get_eta(db: &PgPool) -> i64 { 104async fn get_eta(db: &PgPool) -> i64 {
105 let query = sqlx::query!( 105 let query = sqlx::query!(
106 r#"SELECT times FROM devices;"# 106 r#"SELECT times FROM devices;"#
107 ).fetch_optional(db).await.unwrap(); 107 ).fetch_one(db).await.unwrap();
108 108
109 match query { 109 let times = match query.times {
110 None => { -1 }, 110 None => { vec![0] },
111 Some(rec) => { 111 Some(t) => t,
112 let times = rec.times.unwrap(); 112 };
113 times.iter().sum::<i64>() / times.len() as i64 113 times.iter().sum::<i64>() / times.len() as i64
114 }
115 }
116 114
117} 115}
118 116