Skip to content

Commit

Permalink
Merge pull request #416 from btpworks/fix/cargo-clippy
Browse files Browse the repository at this point in the history
refactor code to pass cargo clippy tests
  • Loading branch information
mtbc authored Nov 20, 2023
2 parents 689d45f + a78d1bd commit 2091ace
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion crates/api/src/chronicle_graphql/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Utc>::from_utc(
Some(DateTime::<Utc>::from_naive_utc_and_offset(
NaiveDateTime::new(
NaiveDate::from_ymd_opt(1582, 10, 16).unwrap(),
NaiveTime::from_hms_opt(0, 0, 0).unwrap(),
Expand Down
11 changes: 6 additions & 5 deletions crates/api/src/persistence/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -1048,7 +1052,6 @@ impl Store {
.select(schema::entity::external_id)
.load::<String>(connection)?
{
let used = used;
model.used(namespaceid.clone(), &id, &EntityId::from_external_id(used));
}

Expand All @@ -1061,7 +1064,6 @@ impl Store {
.select(schema::activity::external_id)
.load::<String>(connection)?
{
let wasinformedby = wasinformedby;
model.was_informed_by(
namespaceid.clone(),
&id,
Expand Down Expand Up @@ -1442,7 +1444,6 @@ impl Store {
.select(schema::entity::external_id)
.load::<String>(connection)?
{
let used = used;
model.used(
namespace.clone(),
activity_id,
Expand Down
8 changes: 4 additions & 4 deletions crates/chronicle-domain-test/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Utc>::from_utc(
let from = DateTime::<Utc>::from_naive_utc_and_offset(
NaiveDate::from_ymd_opt(1968, 9, 1)
.unwrap()
.and_hms_opt(0, 0, 0)
Expand Down Expand Up @@ -2355,7 +2355,7 @@ mod test {

let test_activity = chronicle::async_graphql::Name::new("ItemCertified");

let from = DateTime::<Utc>::from_utc(
let from = DateTime::<Utc>::from_naive_utc_and_offset(
NaiveDate::from_ymd_opt(2023, 3, 20)
.unwrap()
.and_hms_opt(0, 0, 0)
Expand All @@ -2370,7 +2370,7 @@ mod test {

let test_agent = chronicle::async_graphql::Name::new("Certifier");

let to = DateTime::<Utc>::from_utc(
let to = DateTime::<Utc>::from_naive_utc_and_offset(
NaiveDate::from_ymd_opt(2023, 3, 21)
.unwrap()
.and_hms_opt(0, 0, 0)
Expand Down Expand Up @@ -3119,7 +3119,7 @@ mod test {

tokio::time::sleep(Duration::from_millis(1000)).await;

let from = DateTime::<Utc>::from_utc(
let from = DateTime::<Utc>::from_naive_utc_and_offset(
NaiveDate::from_ymd_opt(1968, 9, 1)
.unwrap()
.and_hms_opt(0, 0, 0)
Expand Down
1 change: 1 addition & 0 deletions crates/chronicle/src/bootstrap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ where
Ok(())
}

#[cfg(not(feature = "inmem"))]
fn namespace_bindings(options: &ArgMatches) -> Vec<NamespaceId> {
options
.values_of("namespace-bindings")
Expand Down
4 changes: 2 additions & 2 deletions crates/chronicle/src/codegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down

0 comments on commit 2091ace

Please sign in to comment.