diff --git a/backend/src/api/stats.rs b/backend/src/api/stats.rs index 9974de3..bdf428e 100644 --- a/backend/src/api/stats.rs +++ b/backend/src/api/stats.rs @@ -40,14 +40,13 @@ async fn get_stats(db: &DatabaseConnection) -> anyhow::Result { // todo implement this values somehow let avg_queue_wait_time: u32 = 42; - let avg_build_time: u32 = 42; // Calculate repo storage size let repo_storage_size: u64 = dir_size("repo/").unwrap_or(0); // Count active builds - let active_builds: u32 = Builds::find() - .filter(builds::Column::Status.eq(0)) + let enqueued_builds: u32 = Builds::find() + .filter(builds::Column::Status.eq(3)) .count(db) .await? .try_into()?; @@ -57,13 +56,14 @@ async fn get_stats(db: &DatabaseConnection) -> anyhow::Result { avg_build_time: f64, } - let unique: BuildTimeStruct = BuildTimeStruct::find_by_statement(Statement::from_sql_and_values( - DbBackend::Sqlite, - r#"SELECT AVG((builds.end_time - builds.start_time)) AS avg_build_time + let unique: BuildTimeStruct = + BuildTimeStruct::find_by_statement(Statement::from_sql_and_values( + DbBackend::Sqlite, + r#"SELECT AVG((builds.end_time - builds.start_time)) AS avg_build_time FROM builds WHERE builds.end_time IS NOT NULL AND builds.status = 1;"#, - [], - )) + [], + )) .one(db) .await? .ok_or(anyhow::anyhow!("No Average build time"))?; @@ -79,7 +79,7 @@ async fn get_stats(db: &DatabaseConnection) -> anyhow::Result { avg_queue_wait_time, avg_build_time, repo_storage_size, - active_builds, + enqueued_builds, total_packages, }) } diff --git a/backend/src/api/types/input.rs b/backend/src/api/types/input.rs index e0a2327..214e049 100644 --- a/backend/src/api/types/input.rs +++ b/backend/src/api/types/input.rs @@ -42,6 +42,6 @@ pub struct ListStats { pub avg_queue_wait_time: u32, pub avg_build_time: u32, pub repo_storage_size: u64, - pub active_builds: u32, + pub enqueued_builds: u32, pub total_packages: u32, } diff --git a/frontend/lib/components/dashboard/builds_chart.dart b/frontend/lib/components/dashboard/builds_chart.dart index 052f37b..b7ed3b4 100644 --- a/frontend/lib/components/dashboard/builds_chart.dart +++ b/frontend/lib/components/dashboard/builds_chart.dart @@ -100,7 +100,7 @@ class _BuildsChartState extends State { ); case 2: return PieChartSectionData( - color: const Color(0xff9d8d00), + color: const Color(0xFF0044AA), value: (widget.nrActiveBuilds).toDouble(), title: "${((widget.nrActiveBuilds) * 100 / widget.nrbuilds).toStringAsFixed(2)}%", diff --git a/frontend/lib/components/dashboard/quick_info_banner.dart b/frontend/lib/components/dashboard/quick_info_banner.dart index 1aa1f10..930d207 100644 --- a/frontend/lib/components/dashboard/quick_info_banner.dart +++ b/frontend/lib/components/dashboard/quick_info_banner.dart @@ -46,8 +46,8 @@ class QuickInfoBanner extends StatelessWidget { QuickInfoData( color: const Color(0xFFFFA113), icon: Icons.hourglass_top, - title: "Active Builds", - subtitle: stats.active_builds.toString()), + title: "Enqueued Builds", + subtitle: stats.enqueued_builds.toString()), QuickInfoData( color: const Color(0xFFA4CDFF), icon: Icons.build, diff --git a/frontend/lib/components/dashboard/side_panel.dart b/frontend/lib/components/dashboard/side_panel.dart index f9359a3..8afbda3 100644 --- a/frontend/lib/components/dashboard/side_panel.dart +++ b/frontend/lib/components/dashboard/side_panel.dart @@ -9,12 +9,12 @@ class SidePanel extends StatelessWidget { Key? key, required this.nrbuilds, required this.nrfailedbuilds, - required this.nrActiveBuilds, + required this.nrEnqueuedBuilds, }) : super(key: key); final int nrbuilds; final int nrfailedbuilds; - final int nrActiveBuilds; + final int nrEnqueuedBuilds; @override Widget build(BuildContext context) { @@ -38,7 +38,7 @@ class SidePanel extends StatelessWidget { BuildsChart( nrbuilds: nrbuilds, nrfailedbuilds: nrfailedbuilds, - nrActiveBuilds: nrActiveBuilds), + nrActiveBuilds: nrEnqueuedBuilds), SideCard( color: const Color(0xff0a7005), title: "Successful Builds", @@ -54,11 +54,11 @@ class SidePanel extends StatelessWidget { subtitle: nrfailedbuilds.toString(), ), SideCard( - color: const Color(0xff9d8d00), - title: "Active Builds", + color: const Color(0xFF0044AA), + title: "Enqueued Builds", textRight: - "${(nrActiveBuilds * 100 / nrbuilds).toStringAsFixed(2)}%", - subtitle: nrActiveBuilds.toString(), + "${(nrEnqueuedBuilds * 100 / nrbuilds).toStringAsFixed(2)}%", + subtitle: nrEnqueuedBuilds.toString(), ), ], ), diff --git a/frontend/lib/models/stats.dart b/frontend/lib/models/stats.dart index a00544d..6eeccd1 100644 --- a/frontend/lib/models/stats.dart +++ b/frontend/lib/models/stats.dart @@ -3,7 +3,7 @@ class Stats { failed_builds, avg_queue_wait_time, repo_storage_size, - active_builds, + enqueued_builds, total_packages; final Duration avg_build_time; @@ -14,7 +14,7 @@ class Stats { avg_queue_wait_time: json["avg_queue_wait_time"] as int, avg_build_time: Duration(seconds: json["avg_build_time"]), repo_storage_size: json["repo_storage_size"] as int, - active_builds: json["active_builds"] as int, + enqueued_builds: json["enqueued_builds"] as int, total_packages: json["total_packages"] as int, ); } @@ -25,6 +25,6 @@ class Stats { required this.avg_queue_wait_time, required this.avg_build_time, required this.repo_storage_size, - required this.active_builds, + required this.enqueued_builds, required this.total_packages}); } diff --git a/frontend/lib/screens/dashboard_screen.dart b/frontend/lib/screens/dashboard_screen.dart index c8e2114..a161a6c 100644 --- a/frontend/lib/screens/dashboard_screen.dart +++ b/frontend/lib/screens/dashboard_screen.dart @@ -60,7 +60,7 @@ class _DashboardScreenState extends State { SidePanel( nrbuilds: stats.total_builds, nrfailedbuilds: stats.failed_builds, - nrActiveBuilds: stats.active_builds), + nrEnqueuedBuilds: stats.enqueued_builds), ], ), ), @@ -73,7 +73,7 @@ class _DashboardScreenState extends State { child: SidePanel( nrbuilds: stats.total_builds, nrfailedbuilds: stats.failed_builds, - nrActiveBuilds: stats.active_builds), + nrEnqueuedBuilds: stats.enqueued_builds), ), ], )