From e27dc386b86ce97c42ebb3e1f902433fc8df7de8 Mon Sep 17 00:00:00 2001 From: "Mark T. B. Carroll" Date: Wed, 11 Oct 2023 14:29:13 +0100 Subject: [PATCH 1/3] refactor(api,codegen): update from deprecated datetime conversion method replace from_utc with from_naive_utc_and_offset Signed-off-by: Mark T. B. Carroll --- crates/api/src/chronicle_graphql/query.rs | 2 +- crates/api/src/persistence/mod.rs | 8 ++++++-- crates/chronicle-domain-test/src/test.rs | 8 ++++---- crates/chronicle/src/codegen/mod.rs | 4 ++-- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/crates/api/src/chronicle_graphql/query.rs b/crates/api/src/chronicle_graphql/query.rs index 12d1ec895..278535ac7 100644 --- a/crates/api/src/chronicle_graphql/query.rs +++ b/crates/api/src/chronicle_graphql/query.rs @@ -41,7 +41,7 @@ pub async fn activity_timeline<'a>( // Default from and to to the maximum possible time range let from = from.or_else(|| { - Some(DateTime::::from_utc( + Some(DateTime::::from_naive_utc_and_offset( NaiveDateTime::new( NaiveDate::from_ymd_opt(1582, 10, 16).unwrap(), NaiveTime::from_hms_opt(0, 0, 0).unwrap(), diff --git a/crates/api/src/persistence/mod.rs b/crates/api/src/persistence/mod.rs index ab6588fec..4cf3c10d7 100644 --- a/crates/api/src/persistence/mod.rs +++ b/crates/api/src/persistence/mod.rs @@ -1007,8 +1007,12 @@ impl Store { id: id.clone(), namespaceid: namespaceid.clone(), external_id: activity.external_id.into(), - started: activity.started.map(|x| DateTime::from_utc(x, Utc)), - ended: activity.ended.map(|x| DateTime::from_utc(x, Utc)), + started: activity + .started + .map(|x| DateTime::from_naive_utc_and_offset(x, Utc)), + ended: activity + .ended + .map(|x| DateTime::from_naive_utc_and_offset(x, Utc)), domaintypeid: activity.domaintype.map(DomaintypeId::from_external_id), attributes: attributes .into_iter() diff --git a/crates/chronicle-domain-test/src/test.rs b/crates/chronicle-domain-test/src/test.rs index 474768d3d..be356fb70 100644 --- a/crates/chronicle-domain-test/src/test.rs +++ b/crates/chronicle-domain-test/src/test.rs @@ -557,7 +557,7 @@ mod test { async fn api_calls_resulting_in_no_data_changes_return_null() { let (schema, _database) = test_schema().await; - let from = DateTime::::from_utc( + let from = DateTime::::from_naive_utc_and_offset( NaiveDate::from_ymd_opt(1968, 9, 1) .unwrap() .and_hms_opt(0, 0, 0) @@ -2355,7 +2355,7 @@ mod test { let test_activity = chronicle::async_graphql::Name::new("ItemCertified"); - let from = DateTime::::from_utc( + let from = DateTime::::from_naive_utc_and_offset( NaiveDate::from_ymd_opt(2023, 3, 20) .unwrap() .and_hms_opt(0, 0, 0) @@ -2370,7 +2370,7 @@ mod test { let test_agent = chronicle::async_graphql::Name::new("Certifier"); - let to = DateTime::::from_utc( + let to = DateTime::::from_naive_utc_and_offset( NaiveDate::from_ymd_opt(2023, 3, 21) .unwrap() .and_hms_opt(0, 0, 0) @@ -3119,7 +3119,7 @@ mod test { tokio::time::sleep(Duration::from_millis(1000)).await; - let from = DateTime::::from_utc( + let from = DateTime::::from_naive_utc_and_offset( NaiveDate::from_ymd_opt(1968, 9, 1) .unwrap() .and_hms_opt(0, 0, 0) diff --git a/crates/chronicle/src/codegen/mod.rs b/crates/chronicle/src/codegen/mod.rs index 1d2829295..bc501ab6f 100644 --- a/crates/chronicle/src/codegen/mod.rs +++ b/crates/chronicle/src/codegen/mod.rs @@ -362,12 +362,12 @@ fn gen_activity_definition(activity: &ActivityDef) -> rust::Tokens { #[doc = #_(#start_doc)] async fn started(&self) -> Option<#date_time<#utc>> { - self.0.started.map(|x| #date_time::from_utc(x, #utc)) + self.0.started.map(|x| #date_time::from_naive_utc_and_offset(x, #utc)) } #[doc = #_(#end_doc)] async fn ended(&self) -> Option<#date_time<#utc>> { - self.0.ended.map(|x| #date_time::from_utc(x, #utc)) + self.0.ended.map(|x| #date_time::from_naive_utc_and_offset(x, #utc)) } #[doc = #_(#type_doc)] From 547d3f2b4c79251357b75a9173b217ed0c543b71 Mon Sep 17 00:00:00 2001 From: "Mark T. B. Carroll" Date: Wed, 11 Oct 2023 15:37:40 +0100 Subject: [PATCH 2/3] refactor(bootstrap): remove unused function from inmem build namespace_bindings Signed-off-by: Mark T. B. Carroll --- crates/chronicle/src/bootstrap/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/chronicle/src/bootstrap/mod.rs b/crates/chronicle/src/bootstrap/mod.rs index be2e17b7c..12f35bffb 100644 --- a/crates/chronicle/src/bootstrap/mod.rs +++ b/crates/chronicle/src/bootstrap/mod.rs @@ -172,6 +172,7 @@ where Ok(()) } +#[cfg(not(feature = "inmem"))] fn namespace_bindings(options: &ArgMatches) -> Vec { options .values_of("namespace-bindings") From a78d1bdf7da4440e98fe5e08bdbafe0886da7810 Mon Sep 17 00:00:00 2001 From: "Mark T. B. Carroll" Date: Wed, 11 Oct 2023 15:38:20 +0100 Subject: [PATCH 3/3] refactor(persistence): remove useless redefinitions Signed-off-by: Mark T. B. Carroll --- crates/api/src/persistence/mod.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/crates/api/src/persistence/mod.rs b/crates/api/src/persistence/mod.rs index 4cf3c10d7..46aaeb5a2 100644 --- a/crates/api/src/persistence/mod.rs +++ b/crates/api/src/persistence/mod.rs @@ -1052,7 +1052,6 @@ impl Store { .select(schema::entity::external_id) .load::(connection)? { - let used = used; model.used(namespaceid.clone(), &id, &EntityId::from_external_id(used)); } @@ -1065,7 +1064,6 @@ impl Store { .select(schema::activity::external_id) .load::(connection)? { - let wasinformedby = wasinformedby; model.was_informed_by( namespaceid.clone(), &id, @@ -1446,7 +1444,6 @@ impl Store { .select(schema::entity::external_id) .load::(connection)? { - let used = used; model.used( namespace.clone(), activity_id,