Skip to content
Merged
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
23 changes: 22 additions & 1 deletion src/client/models/simulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,21 @@ fn truncate(s: &str, max: usize) -> String {
}
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SubvalueByTimestamp {
pub start_offset: f64,
pub end_offset: f64,
pub output_type: String,
#[serde(default)]
pub float_value: f64,
#[serde(default)]
pub string_value: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub role: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub message_index: Option<i64>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SimpleMetricOutput {
pub metric_output_id: String,
Expand All @@ -127,6 +142,8 @@ pub struct SimpleMetricOutput {
pub status: Option<String>,
#[serde(default)]
pub value: Option<serde_json::Value>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub subvalues_by_timestamp: Option<Vec<SubvalueByTimestamp>>,
}

#[derive(Debug, Deserialize)]
Expand All @@ -141,7 +158,7 @@ pub struct GetSimulationMetricResponse {

impl Tabular for SimpleMetricOutput {
fn headers() -> Vec<&'static str> {
vec!["OUTPUT ID", "METRIC ID", "STATUS", "VALUE"]
vec!["OUTPUT ID", "METRIC ID", "STATUS", "VALUE", "SUBVALUES"]
}

fn row(&self) -> Vec<String> {
Expand All @@ -153,6 +170,10 @@ impl Tabular for SimpleMetricOutput {
.as_ref()
.map(|v| truncate(&v.to_string(), 30))
.unwrap_or_else(|| "-".into()),
self.subvalues_by_timestamp
.as_ref()
.map(|sv| format!("{}", sv.len()))
.unwrap_or_else(|| "-".into()),
]
}
}
Loading