eba4fd1
use admin::services::act::{AdminActRunDto, AdminActRunPage, AdminActSummary};
use crate::convert::{opt_ts, ts};
use crate::proto as pb;
pub fn summary(value: AdminActSummary) -> pb::ActSummary {
pb::ActSummary {
runners_total: value.runners_total,
runners_active: value.runners_active,
runners_busy: value.runners_busy,
jobs_queued: value.jobs_queued,
jobs_running: value.jobs_running,
runs_queued: value.runs_queued,
runs_running: value.runs_running,
runs_success: value.runs_success,
runs_failure: value.runs_failure,
generated_at: ts(value.generated_at),
}
}
pub fn run(value: AdminActRunDto) -> pb::ActRun {
pb::ActRun {
id: value.id.to_string(),
repo_id: value.repo_id.to_string(),
repo_name: value.repo_name,
repo_full_name: value.repo_full_name,
space_id: value.space_id.map(|value| value.to_string()),
space_name: value.space_name,
workflow_file: value.workflow_file,
workflow_name: value.workflow_name,
display_name: value.display_name,
actions_id: value.actions_id,
run_number: value.run_number,
event: value.event,
state: value.state,
commit_sha: value.commit_sha,
branch: value.branch,
tag: value.tag,
pr_number: value.pr_number,
jobs_total: value.jobs_total,
jobs_active: value.jobs_active,
jobs_failed: value.jobs_failed,
created_at: ts(value.created_at),
started_at: opt_ts(value.started_at),
finished_at: opt_ts(value.finished_at),
}
}
pub fn run_page(value: AdminActRunPage) -> pb::ActRunPage {
pb::ActRunPage {
items: value.items.into_iter().map(run).collect(),
total: value.total,
limit: value.limit,
offset: value.offset,
}
}