summaryrefslogtreecommitdiff
path: root/src/dbctx.rs
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2023-07-04 14:21:58 -0700
committeriximeow <me@iximeow.net>2023-07-04 14:21:58 -0700
commitd0e845d3ac4530cf281e90d8a3634355d153c8be (patch)
tree6d679b58170adf6b9c8bdc2e53e836413c6458ed /src/dbctx.rs
parent0f97747c2e3e6f3178e414adc5b6022ead275601 (diff)
adjust metrics to show multi-host summaries?
Diffstat (limited to 'src/dbctx.rs')
-rw-r--r--src/dbctx.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/dbctx.rs b/src/dbctx.rs
index ae06d21..0c7d488 100644
--- a/src/dbctx.rs
+++ b/src/dbctx.rs
@@ -666,6 +666,34 @@ impl DbCtx {
.map_err(|e| e.to_string())
}
+ pub fn host_model_info(&self, host_id: u64) -> Result<(String, String, String, String), String> {
+ let conn = self.conn.lock().unwrap();
+ conn
+ .query_row("select hostname, cpu_vendor_id, cpu_family, cpu_model from hosts;", [host_id], |row| {
+ Ok((
+ row.get(0).unwrap(),
+ row.get(1).unwrap(),
+ row.get(2).unwrap(),
+ row.get(3).unwrap(),
+ ))
+ })
+ .map_err(|e| e.to_string())
+ }
+
+ pub fn runs_for_job_one_per_host(&self, job_id: u64) -> Result<Vec<Run>, String> {
+ let conn = self.conn.lock().unwrap();
+ let mut runs_query = conn.prepare(crate::sql::RUNS_FOR_JOB).unwrap();
+ let mut runs_results = runs_query.query([job_id]).unwrap();
+
+ let mut results = Vec::new();
+
+ while let Some(row) = runs_results.next().unwrap() {
+ results.push(crate::sql::row2run(row));
+ }
+
+ Ok(results)
+ }
+
pub fn last_run_for_job(&self, job_id: u64) -> Result<Option<Run>, String> {
let conn = self.conn.lock().unwrap();