diff options
Diffstat (limited to 'src/services/ping.rs')
-rw-r--r-- | src/services/ping.rs | 14 |
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>) { | |||
104 | async fn get_eta(db: &PgPool) -> i64 { | 104 | async 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 | ||