set pkg to build state when already existing and starting build
add active builds to right cake graph
This commit is contained in:
parent
600c2057fe
commit
695f451763
@ -28,7 +28,7 @@ pub async fn package_add(
|
||||
) -> Result<(), BadRequest<String>> {
|
||||
let db = db as &DatabaseConnection;
|
||||
|
||||
let pkt_model = match Packages::find()
|
||||
let mut pkg_model = match Packages::find()
|
||||
.filter(packages::Column::Name.eq(input.name.clone()))
|
||||
.one(db)
|
||||
.await
|
||||
@ -37,6 +37,7 @@ pub async fn package_add(
|
||||
None => {
|
||||
let new_package = packages::ActiveModel {
|
||||
name: Set(input.name.clone()),
|
||||
status: Set(0),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
@ -58,7 +59,7 @@ pub async fn package_add(
|
||||
None => {
|
||||
let new_version = versions::ActiveModel {
|
||||
version: Set(pkg.version.clone()),
|
||||
package_id: Set(pkt_model.id.clone().unwrap()),
|
||||
package_id: Set(pkg_model.id.clone().unwrap()),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
@ -75,6 +76,11 @@ pub async fn package_add(
|
||||
}
|
||||
};
|
||||
|
||||
if pkg_model.status.unwrap() != 0 {
|
||||
pkg_model.status = Set(0);
|
||||
pkg_model.save(db).await.expect("todo error message");
|
||||
}
|
||||
|
||||
let _ = tx.send(Action::Build(
|
||||
pkg.name,
|
||||
pkg.version,
|
||||
|
@ -12,8 +12,6 @@ use rocket_okapi::{openapi, JsonSchema};
|
||||
use sea_orm::PaginatorTrait;
|
||||
use sea_orm::{ColumnTrait, QueryFilter};
|
||||
use sea_orm::{DatabaseConnection, EntityTrait, FromQueryResult, QuerySelect, RelationTrait};
|
||||
use std::path::PathBuf;
|
||||
use std::{fs, io};
|
||||
|
||||
#[derive(Serialize, JsonSchema)]
|
||||
#[serde(crate = "rocket::serde")]
|
||||
|
@ -6,10 +6,12 @@ class BuildsChart extends StatefulWidget {
|
||||
Key? key,
|
||||
required this.nrbuilds,
|
||||
required this.nrfailedbuilds,
|
||||
required this.nrActiveBuilds,
|
||||
}) : super(key: key);
|
||||
|
||||
final int nrbuilds;
|
||||
final int nrfailedbuilds;
|
||||
final int nrActiveBuilds;
|
||||
|
||||
@override
|
||||
_BuildsChartState createState() => _BuildsChartState();
|
||||
@ -36,6 +38,7 @@ class _BuildsChartState extends State<BuildsChart> {
|
||||
pieTouchData: PieTouchData(
|
||||
touchCallback: (pieTouchResponse, touchresponse) {
|
||||
setState(() {
|
||||
// todo hover gesture not working properly
|
||||
if (touchresponse?.touchedSection != null) {
|
||||
touchedIndex = touchresponse!
|
||||
.touchedSection!.touchedSectionIndex;
|
||||
@ -63,7 +66,7 @@ class _BuildsChartState extends State<BuildsChart> {
|
||||
}
|
||||
|
||||
List<PieChartSectionData> showingSections() {
|
||||
return List.generate(2, (i) {
|
||||
return List.generate(3, (i) {
|
||||
final isTouched = i == touchedIndex;
|
||||
final fontSize = isTouched ? 25.0 : 16.0;
|
||||
final radius = isTouched ? 60.0 : 50.0;
|
||||
@ -83,9 +86,24 @@ class _BuildsChartState extends State<BuildsChart> {
|
||||
case 1:
|
||||
return PieChartSectionData(
|
||||
color: const Color(0xff0a7005),
|
||||
value: (widget.nrbuilds - widget.nrfailedbuilds).toDouble(),
|
||||
value: (widget.nrbuilds -
|
||||
widget.nrfailedbuilds -
|
||||
widget.nrActiveBuilds)
|
||||
.toDouble(),
|
||||
title:
|
||||
"${((widget.nrbuilds - widget.nrfailedbuilds) * 100 / widget.nrbuilds).toStringAsFixed(2)}%",
|
||||
"${((widget.nrbuilds - widget.nrfailedbuilds - widget.nrActiveBuilds) * 100 / widget.nrbuilds).toStringAsFixed(2)}%",
|
||||
radius: radius,
|
||||
titleStyle: TextStyle(
|
||||
fontSize: fontSize,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: const Color(0xffffffff)),
|
||||
);
|
||||
case 2:
|
||||
return PieChartSectionData(
|
||||
color: const Color(0xff9d8d00),
|
||||
value: (widget.nrActiveBuilds).toDouble(),
|
||||
title:
|
||||
"${((widget.nrActiveBuilds) * 100 / widget.nrbuilds).toStringAsFixed(2)}%",
|
||||
radius: radius,
|
||||
titleStyle: TextStyle(
|
||||
fontSize: fontSize,
|
||||
|
@ -42,10 +42,10 @@ class _RecentBuildsState extends State<RecentBuilds> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(defaultPadding),
|
||||
decoration: BoxDecoration(
|
||||
padding: const EdgeInsets.all(defaultPadding),
|
||||
decoration: const BoxDecoration(
|
||||
color: secondaryColor,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
||||
borderRadius: BorderRadius.all(Radius.circular(10)),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@ -97,9 +97,12 @@ class _RecentBuildsState extends State<RecentBuilds> {
|
||||
DataCell(Text(build.id.toString())),
|
||||
DataCell(Text(build.pkg_name)),
|
||||
DataCell(Text(build.version)),
|
||||
DataCell(Icon(
|
||||
switchSuccessIcon(build.status),
|
||||
color: switchSuccessColor(build.status),
|
||||
DataCell(IconButton(
|
||||
icon: Icon(
|
||||
switchSuccessIcon(build.status),
|
||||
color: switchSuccessColor(build.status),
|
||||
),
|
||||
onPressed: () {},
|
||||
)),
|
||||
],
|
||||
);
|
||||
|
@ -9,10 +9,12 @@ class SidePanel extends StatelessWidget {
|
||||
Key? key,
|
||||
required this.nrbuilds,
|
||||
required this.nrfailedbuilds,
|
||||
required this.nrActiveBuilds,
|
||||
}) : super(key: key);
|
||||
|
||||
final int nrbuilds;
|
||||
final int nrfailedbuilds;
|
||||
final int nrActiveBuilds;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -33,7 +35,10 @@ class SidePanel extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: defaultPadding),
|
||||
BuildsChart(nrbuilds: nrbuilds, nrfailedbuilds: nrfailedbuilds),
|
||||
BuildsChart(
|
||||
nrbuilds: nrbuilds,
|
||||
nrfailedbuilds: nrfailedbuilds,
|
||||
nrActiveBuilds: nrActiveBuilds),
|
||||
ChartCard(
|
||||
color: const Color(0xff0a7005),
|
||||
title: "Successful Builds",
|
||||
@ -48,6 +53,13 @@ class SidePanel extends StatelessWidget {
|
||||
"${(nrfailedbuilds * 100 / nrbuilds).toStringAsFixed(2)}%",
|
||||
subtitle: nrfailedbuilds.toString(),
|
||||
),
|
||||
ChartCard(
|
||||
color: const Color(0xff9d8d00),
|
||||
title: "Active Builds",
|
||||
textRight:
|
||||
"${(nrActiveBuilds * 100 / nrbuilds).toStringAsFixed(2)}%",
|
||||
subtitle: nrActiveBuilds.toString(),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
@ -49,7 +49,8 @@ class DashboardScreen extends StatelessWidget {
|
||||
if (Responsive.isMobile(context))
|
||||
SidePanel(
|
||||
nrbuilds: stats.total_builds,
|
||||
nrfailedbuilds: stats.failed_builds),
|
||||
nrfailedbuilds: stats.failed_builds,
|
||||
nrActiveBuilds: stats.active_builds),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -61,7 +62,8 @@ class DashboardScreen extends StatelessWidget {
|
||||
flex: 2,
|
||||
child: SidePanel(
|
||||
nrbuilds: stats.total_builds,
|
||||
nrfailedbuilds: stats.failed_builds),
|
||||
nrfailedbuilds: stats.failed_builds,
|
||||
nrActiveBuilds: stats.active_builds),
|
||||
),
|
||||
],
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user