Skip to content

Commit

Permalink
feat: skip hidden workers in dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
jiegec committed Jun 1, 2024
1 parent e146ded commit a33c5d3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions server/src/routes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,21 @@ 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
.select((
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<i64>, Option<bigdecimal::BigDecimal>)>(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)?;

Expand All @@ -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<i64>, Option<bigdecimal::BigDecimal>)>(conn)?
{
by_arch.entry(arch.clone()).or_default().total_worker_count = count;
Expand Down

0 comments on commit a33c5d3

Please sign in to comment.