From 500e18024167d937a0c3585fbcd2122662a200c4 Mon Sep 17 00:00:00 2001 From: beckerinj Date: Thu, 24 Nov 2022 23:39:00 -0800 Subject: [PATCH] update status enum --- core/src/api/build.rs | 2 +- core/src/api/deployment.rs | 2 +- core/src/api/server.rs | 2 +- lib/types/src/lib.rs | 19 +++++++++++++++++-- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/core/src/api/build.rs b/core/src/api/build.rs index 66b4de099..a9ca78b8e 100644 --- a/core/src/api/build.rs +++ b/core/src/api/build.rs @@ -49,7 +49,7 @@ async fn create( target: UpdateTarget::Build(build_id), operation: Operation::CreateBuild, start_ts, - end_ts: unix_timestamp_ms() as i64, + end_ts: Some(unix_timestamp_ms() as i64), operator: user.id.clone(), ..Default::default() }; diff --git a/core/src/api/deployment.rs b/core/src/api/deployment.rs index 28aaa3a94..b67cad513 100644 --- a/core/src/api/deployment.rs +++ b/core/src/api/deployment.rs @@ -39,7 +39,7 @@ async fn create( target: UpdateTarget::Deployment(deployment_id), operation: Operation::CreateDeployment, start_ts, - end_ts: unix_timestamp_ms() as i64, + end_ts: Some(unix_timestamp_ms() as i64), operator: user.id.clone(), ..Default::default() }; diff --git a/core/src/api/server.rs b/core/src/api/server.rs index fb2ab26fe..9ab7defab 100644 --- a/core/src/api/server.rs +++ b/core/src/api/server.rs @@ -83,7 +83,7 @@ async fn create( target: UpdateTarget::Server(server_id), operation: Operation::CreateServer, start_ts, - end_ts: unix_timestamp_ms() as i64, + end_ts: Some(unix_timestamp_ms() as i64), operator: user.id.clone(), ..Default::default() }; diff --git a/lib/types/src/lib.rs b/lib/types/src/lib.rs index e08a0ea01..2b941d811 100644 --- a/lib/types/src/lib.rs +++ b/lib/types/src/lib.rs @@ -156,8 +156,8 @@ pub struct Update { pub operation: Operation, pub log: Vec, pub start_ts: i64, - pub end_ts: i64, - pub in_progress: bool, + pub end_ts: Option, + pub status: UpdateStatus, pub is_error: bool, pub operator: String, } @@ -395,6 +395,21 @@ impl Default for UpdateTarget { } } +#[derive(Serialize, Deserialize, Debug, Display, EnumString, PartialEq, Hash, Eq, Clone, Copy)] +#[serde(rename_all = "snake_case")] +#[strum(serialize_all = "snake_case")] +pub enum UpdateStatus { + Queued, + InProgress, + Complete, +} + +impl Default for UpdateStatus { + fn default() -> Self { + UpdateStatus::Complete + } +} + #[derive(Serialize, Deserialize, Debug, Display, EnumString, PartialEq, Hash, Eq, Clone, Copy)] #[serde(rename_all = "snake_case")] #[strum(serialize_all = "snake_case")]