show enqueued build in banner instead of active ones
This commit is contained in:
parent
ed57e14bef
commit
4ffb4b2855
@ -40,14 +40,13 @@ async fn get_stats(db: &DatabaseConnection) -> anyhow::Result<ListStats> {
|
||||
|
||||
// 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<ListStats> {
|
||||
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<ListStats> {
|
||||
avg_queue_wait_time,
|
||||
avg_build_time,
|
||||
repo_storage_size,
|
||||
active_builds,
|
||||
enqueued_builds,
|
||||
total_packages,
|
||||
})
|
||||
}
|
||||
|
@ -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,
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ class _BuildsChartState extends State<BuildsChart> {
|
||||
);
|
||||
case 2:
|
||||
return PieChartSectionData(
|
||||
color: const Color(0xff9d8d00),
|
||||
color: const Color(0xFF0044AA),
|
||||
value: (widget.nrActiveBuilds).toDouble(),
|
||||
title:
|
||||
"${((widget.nrActiveBuilds) * 100 / widget.nrbuilds).toStringAsFixed(2)}%",
|
||||
|
@ -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,
|
||||
|
@ -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(),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@ -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});
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
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<DashboardScreen> {
|
||||
child: SidePanel(
|
||||
nrbuilds: stats.total_builds,
|
||||
nrfailedbuilds: stats.failed_builds,
|
||||
nrActiveBuilds: stats.active_builds),
|
||||
nrEnqueuedBuilds: stats.enqueued_builds),
|
||||
),
|
||||
],
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user