From a33c5d31dfb7833d55a3731bff8f3d77bf8ed691 Mon Sep 17 00:00:00 2001 From: Jiajie Chen Date: Sat, 1 Jun 2024 11:09:02 +0800 Subject: [PATCH] feat: skip hidden workers in dashboard --- server/src/routes/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server/src/routes/mod.rs b/server/src/routes/mod.rs index 82ba815..38ec404 100644 --- a/server/src/routes/mod.rs +++ b/server/src/routes/mod.rs @@ -112,6 +112,7 @@ pub async fn dashboard_status( .count() .get_result(conn)?; let total_worker_count = crate::schema::workers::dsl::workers + .filter(crate::schema::workers::dsl::visible.eq(true)) .count() .get_result(conn)?; let (total_logical_cores, total_memory_bytes) = crate::schema::workers::dsl::workers @@ -119,11 +120,13 @@ pub async fn dashboard_status( sum(crate::schema::workers::dsl::logical_cores), sum(crate::schema::workers::dsl::memory_bytes), )) + .filter(crate::schema::workers::dsl::visible.eq(true)) .get_result::<(Option, Option)>(conn)?; let deadline = Utc::now() - chrono::Duration::try_seconds(HEARTBEAT_TIMEOUT).unwrap(); let live_worker_count = crate::schema::workers::dsl::workers .filter(crate::schema::workers::last_heartbeat_time.gt(deadline)) + .filter(crate::schema::workers::dsl::visible.eq(true)) .count() .get_result(conn)?; @@ -138,6 +141,7 @@ pub async fn dashboard_status( sum(crate::schema::workers::dsl::logical_cores), sum(crate::schema::workers::dsl::memory_bytes), )) + .filter(crate::schema::workers::dsl::visible.eq(true)) .load::<(String, i64, Option, Option)>(conn)? { by_arch.entry(arch.clone()).or_default().total_worker_count = count;