evg_api_rs/models/
build.rs

1use chrono::{DateTime, Utc};
2use serde::Deserialize;
3
4#[derive(Debug, Default, Deserialize, Clone)]
5pub struct BuildStatusCounts {
6    pub succeeded: u32,
7    pub failed: u32,
8    pub started: u32,
9    pub undispatched: u32,
10    pub inactivate: Option<u32>,
11    pub dispatched: u32,
12    pub timed_out: u32,
13}
14
15impl BuildStatusCounts {
16    pub fn new() -> Self {
17        Self {
18            ..Default::default()
19        }
20    }
21
22    pub fn add(&mut self, other: &Self) {
23        self.succeeded += other.succeeded;
24        self.failed += other.failed;
25        self.started += other.started;
26        self.undispatched += other.undispatched;
27        self.dispatched += other.dispatched;
28        self.timed_out += other.timed_out;
29    }
30
31    pub fn total_task_count(&self) -> u32 {
32        self.undispatched
33            + self.dispatched
34            + self.started
35            + self.failed
36            + self.succeeded
37            + self.timed_out
38    }
39
40    pub fn finished_task_count(&self) -> u32 {
41        self.succeeded + self.failed + self.timed_out
42    }
43
44    pub fn pending_task_count(&self) -> u32 {
45        self.started + self.undispatched
46    }
47
48    pub fn completed_task_count(&self) -> u32 {
49        self.failed + self.succeeded + self.timed_out
50    }
51
52    pub fn percent_complete(&self) -> f64 {
53        self.finished_task_count() as f64 / self.total_task_count() as f64
54    }
55}
56
57#[derive(Debug, Deserialize, Clone)]
58pub struct EvgBuild {
59    #[serde(alias = "_id")]
60    pub id: String,
61    pub project_id: String,
62    pub create_time: Option<DateTime<Utc>>,
63    pub start_time: Option<DateTime<Utc>>,
64    pub finish_time: Option<DateTime<Utc>>,
65    pub version: String,
66    pub branch: Option<String>,
67    pub git_hash: String,
68    pub build_variant: String,
69    pub status: String,
70    pub activated: bool,
71    pub activated_by: String,
72    pub activated_time: Option<DateTime<Utc>>,
73    pub order: u64,
74    pub tasks: Vec<String>,
75    pub time_taken_ms: u64,
76    pub display_name: String,
77    pub predicted_makespan_ms: u64,
78    pub actual_makespan_ms: u64,
79    pub origin: String,
80    pub status_counts: BuildStatusCounts,
81}