Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions orion-server/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use axum::{
response::{IntoResponse, Sse, sse::Event, sse::KeepAlive},
routing::{any, get},
};
use chrono::{DateTime, Utc};
use dashmap::DashMap;
use futures_util::{SinkExt, Stream, StreamExt, stream};
use orion::ws::WSMessage;
Expand Down Expand Up @@ -350,7 +351,7 @@ pub async fn task_handler(
build_id: Set(task_id),
output_file: Set(format!("{}/{}", get_build_log_dir(), task_id)),
exit_code: Set(None),
start_at: Set(chrono::Utc::now()),
start_at: Set(chrono::Utc::now().naive_utc()),
end_at: Set(None),
repo_name: Set(req.repo.clone()),
target: Set(target.clone()),
Expand Down Expand Up @@ -441,7 +442,7 @@ async fn handle_immediate_task_dispatch(
build_id: Set(task_id),
output_file: Set(format!("{}/{}", get_build_log_dir(), task_id)),
exit_code: Set(None),
start_at: Set(build_info.start_at),
start_at: Set(build_info.start_at.naive_utc()),
end_at: Set(None),
repo_name: Set(build_info.repo.clone()),
target: Set(build_info.target.clone()),
Expand Down Expand Up @@ -636,7 +637,7 @@ async fn process_message(
);
}
WSMessage::Heartbeat => {
if let Some(mut worker) = state.scheduler.workers.get_mut(current_worker_id) {
if let Some(mut worker) = state.scheduler.workers.get_mut(current_worker_id) {
worker.last_heartbeat = chrono::Utc::now();
tracing::debug!("Received heartbeat from {current_worker_id}");
}
Expand Down Expand Up @@ -677,7 +678,7 @@ async fn process_message(
let _ = builds::Entity::update_many()
.set(builds::ActiveModel {
exit_code: Set(exit_code),
end_at: Set(Some(chrono::Utc::now())),
end_at: Set(Some(chrono::Utc::now().naive_utc())),
..Default::default()
})
.filter(builds::Column::BuildId.eq(id.parse::<uuid::Uuid>().unwrap()))
Expand Down Expand Up @@ -725,8 +726,8 @@ impl BuildDTO {
build_id: model.build_id.to_string(),
output_file: model.output_file,
exit_code: model.exit_code,
start_at: model.start_at.to_rfc3339(),
end_at: model.end_at.map(|dt| dt.to_rfc3339()),
start_at: DateTime::<Utc>::from_naive_utc_and_offset(model.start_at, Utc).to_rfc3339(),
end_at: model.end_at.map(|dt| DateTime::<Utc>::from_naive_utc_and_offset(dt, Utc).to_rfc3339()),
repo_name: model.repo_name,
target: model.target,
arguments: model.arguments,
Expand Down Expand Up @@ -798,8 +799,8 @@ impl TaskInfoDTO {
build_id: model.build_id.to_string(),
output_file: model.output_file,
exit_code: model.exit_code,
start_at: model.start_at.to_rfc3339(),
end_at: model.end_at.map(|dt| dt.to_rfc3339()),
start_at: DateTime::<Utc>::from_naive_utc_and_offset(model.start_at, Utc).to_rfc3339(),
end_at: model.end_at.map(|dt| DateTime::<Utc>::from_naive_utc_and_offset(dt, Utc).to_rfc3339()),
repo_name: model.repo_name,
target: model.target,
arguments: model.arguments,
Expand Down
13 changes: 7 additions & 6 deletions orion-server/src/model/builds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ use serde::Serialize;
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub build_id: Uuid,
pub output_file: String,
/// Exit code of the build process. None if process was terminated by signal on Unix
pub exit_code: Option<i32>,
pub start_at: DateTimeUtc,
pub end_at: Option<DateTimeUtc>,
pub start_at: DateTime,
pub end_at: Option<DateTime>,
pub repo_name: String,
/// Build target specification (e.g., "//:main")
pub target: String,
#[sea_orm(column_type = "Text")]
pub output_file: String,
#[sea_orm(column_type = "Text")]
pub arguments: String,
/// Merge request identifier
#[sea_orm(column_type = "Text")]
pub mr: String,
}

Expand All @@ -26,6 +26,7 @@ pub enum Relation {}

impl ActiveModelBehavior for ActiveModel {}


impl Model {
/// Retrieves a build record by its UUID from the database
pub async fn get_by_build_id(build_id: Uuid, conn: &DatabaseConnection) -> Option<Model> {
Expand Down
2 changes: 1 addition & 1 deletion orion-server/src/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ impl TaskScheduler {
build_id: Set(pending_task.task_id),
output_file: Set(format!("{}/{}", get_build_log_dir(), pending_task.task_id)),
exit_code: Set(None),
start_at: Set(build_info.start_at),
start_at: Set(build_info.start_at.naive_utc()),
end_at: Set(None),
repo_name: Set(build_info.repo.clone()),
target: Set(build_info.target.clone()),
Expand Down
2 changes: 1 addition & 1 deletion orion-server/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ async fn start_health_check_task(state: AppState) {

let update_res = builds::Entity::update_many()
.set(builds::ActiveModel {
end_at: Set(Some(chrono::Utc::now())),
end_at: Set(Some(chrono::Utc::now().naive_utc())),
..Default::default()
})
.filter(builds::Column::BuildId.eq(task_id.parse::<uuid::Uuid>().unwrap()))
Expand Down
Loading