From a76633b44e6ac6752c186811d97b418af8ec20bc Mon Sep 17 00:00:00 2001 From: lukasmittag Date: Wed, 21 Feb 2024 09:37:10 +0100 Subject: [PATCH] Change default source timestamp to None --- .../databroker/src/grpc/kuksa_val_v1/conversions.rs | 2 +- .../src/grpc/sdv_databroker_v1/conversions.rs | 10 +++++----- kuksa_databroker/databroker/src/viss/v2/server.rs | 1 + 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/kuksa_databroker/databroker/src/grpc/kuksa_val_v1/conversions.rs b/kuksa_databroker/databroker/src/grpc/kuksa_val_v1/conversions.rs index 64cb8075..d9b972d1 100644 --- a/kuksa_databroker/databroker/src/grpc/kuksa_val_v1/conversions.rs +++ b/kuksa_databroker/databroker/src/grpc/kuksa_val_v1/conversions.rs @@ -306,7 +306,7 @@ impl From for broker::Datapoint { source_ts: match from.timestamp { Some(ts) => match std::convert::TryInto::try_into(ts) { Ok(ts) => Some(ts), - Err(_) => Some(SystemTime::now()), + Err(_) => None, }, None => None, }, diff --git a/kuksa_databroker/databroker/src/grpc/sdv_databroker_v1/conversions.rs b/kuksa_databroker/databroker/src/grpc/sdv_databroker_v1/conversions.rs index b7c56972..e028c390 100644 --- a/kuksa_databroker/databroker/src/grpc/sdv_databroker_v1/conversions.rs +++ b/kuksa_databroker/databroker/src/grpc/sdv_databroker_v1/conversions.rs @@ -26,13 +26,13 @@ impl From<&proto::Datapoint> for broker::Datapoint { match &datapoint.timestamp { Some(source_timestamp) => { - let source_ts = source_timestamp - .clone() - .try_into() - .unwrap_or_else(|_| SystemTime::now()); + let source: Option = match source_timestamp.clone().try_into() { + Ok(source) => Some(source), + Err(_) => None, + }; broker::Datapoint { ts, - source_ts: Some(source_ts), + source_ts: source, value, } } diff --git a/kuksa_databroker/databroker/src/viss/v2/server.rs b/kuksa_databroker/databroker/src/viss/v2/server.rs index 01f96fc3..91a69f62 100644 --- a/kuksa_databroker/databroker/src/viss/v2/server.rs +++ b/kuksa_databroker/databroker/src/viss/v2/server.rs @@ -162,6 +162,7 @@ impl Viss for Server { datapoint: None, actuator_target: Some(Some(broker::Datapoint { value: actuator_target, + source_ts: None, ts: SystemTime::now(), })), entry_type: None,