add structured logging

This commit is contained in:
2026-08-18 21:28:48 +01:00
parent 4f3995da17
commit 2879fecf70
8 changed files with 233 additions and 101 deletions
+10 -11
View File
@@ -12,12 +12,10 @@ const DIM_PRESERVATION: &str = "Preservation (EUMOFAPreservation)";
const DIM_SHIPSIZE: &str = "Shipsize";
const DIM_MEASURE: &str = "measure";
const SENTINEL_VALUES: [f64; 1] = [-1.0];
const SENTINEL_VALUE: f64 = -1.0;
fn is_sentinel(v: f64) -> bool {
SENTINEL_VALUES
.iter()
.any(|s| v.total_cmp(s) == std::cmp::Ordering::Equal)
v.total_cmp(&SENTINEL_VALUE) == std::cmp::Ordering::Equal
}
pub async fn fetch_metadata(client: &Client, url: &str) -> Result<(LookupMap, MetadataResponse)> {
@@ -83,13 +81,14 @@ pub fn chunk_months(months: &[String], batch_size: usize) -> Vec<Vec<String>> {
.collect()
}
pub fn build_query(all_months: &[String]) -> Query {
assert!(
!all_months.is_empty(),
"build_query requires at least one month"
);
pub fn build_query(all_months: &[String]) -> Result<Query> {
if all_months.is_empty() {
return Err(IngestError::InvalidValueCode(
"build_query requires at least one month".to_string(),
));
}
Query {
Ok(Query {
query: vec![
QueryItem {
code: DIM_MONTH.to_string(),
@@ -149,7 +148,7 @@ pub fn build_query(all_months: &[String]) -> Query {
},
],
response: QueryResponse::default(),
}
})
}
pub async fn fetch_data(client: &Client, url: &str, query: &Query) -> Result<DataResponse> {