Skip to content

Commit

Permalink
fix: applied cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare committed Jan 11, 2023
1 parent 49664ce commit 7b8b7b3
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 34 deletions.
4 changes: 1 addition & 3 deletions aw-client-rust/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ mod test {
Ok(_) => break,
Err(err) => {
if i == timeout_s - 1 {
panic!(
"Timed out starting aw-server after {timeout_s}s: {err:?}"
);
panic!("Timed out starting aw-server after {timeout_s}s: {err:?}");
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions aw-datastore/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ impl DatastoreWorker {
if self.legacy_import {
let transaction = match conn.transaction_with_behavior(TransactionBehavior::Immediate) {
Ok(transaction) => transaction,
Err(err) => panic!(
"Unable to start immediate transaction on SQLite database! {err}"
),
Err(err) => {
panic!("Unable to start immediate transaction on SQLite database! {err}")
}
};
match ds.ensure_legacy_import(&transaction) {
Ok(_) => (),
Expand Down
2 changes: 0 additions & 2 deletions aw-datastore/tests/datastore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ mod datastore_tests {
}
}

#[cfg(not(target_os = "android"))]

#[cfg(not(target_os = "android"))]
use std::fs;
use std::path::PathBuf;
Expand Down
5 changes: 1 addition & 4 deletions aw-models/src/bucket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,13 @@ pub struct Bucket {
pub last_updated: Option<DateTime<Utc>>, // TODO: Should probably be moved into metadata field
}

#[derive(Serialize, Deserialize, JsonSchema, Clone, Debug)]
#[derive(Default)]
#[derive(Serialize, Deserialize, JsonSchema, Clone, Debug, Default)]
pub struct BucketMetadata {
#[serde(default)]
pub start: Option<DateTime<Utc>>,
pub end: Option<DateTime<Utc>>,
}



#[derive(Serialize, Deserialize, JsonSchema, Clone)]
pub struct BucketsExport {
pub buckets: HashMap<String, Bucket>,
Expand Down
3 changes: 1 addition & 2 deletions aw-models/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ impl Event {
}
}
pub fn calculate_endtime(&self) -> DateTime<Utc> {
self.timestamp
+ chrono::Duration::nanoseconds(self.duration.num_nanoseconds().unwrap())
self.timestamp + chrono::Duration::nanoseconds(self.duration.num_nanoseconds().unwrap())
}
pub fn interval(&self) -> TimeInterval {
TimeInterval::new(self.timestamp, self.calculate_endtime())
Expand Down
4 changes: 1 addition & 3 deletions aw-models/src/tryvec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,7 @@ where
let res = match access.next_element() {
Ok(val) => val,
Err(err) => {
println!(
"Failed to parse event because '{err}', the event will be discarded"
);
println!("Failed to parse event because '{err}', the event will be discarded");
continue;
}
};
Expand Down
17 changes: 10 additions & 7 deletions aw-query/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,20 +212,23 @@ mod qfunctions {
)))
}
};
let bucketname =
match aw_transform::find_bucket(&bucket_filter, &hostname_filter, buckets.values()) {
Some(bucketname) => bucketname,
None => {
return Err(QueryError::BucketQueryError(match hostname_filter {
let bucketname = match aw_transform::find_bucket(
&bucket_filter,
&hostname_filter,
buckets.values(),
) {
Some(bucketname) => bucketname,
None => {
return Err(QueryError::BucketQueryError(match hostname_filter {
None => {
format!("Failed to find bucket matching filter '{bucket_filter}'")
}
Some(hostname_filter) => format!(
"Failed to find bucket matching filter '{bucket_filter}' and hostname '{hostname_filter}'"
),
}));
}
};
}
};
Ok(DataType::String(bucketname))
}

Expand Down
2 changes: 1 addition & 1 deletion aw-query/tests/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ macro_rules! json_map {

#[cfg(test)]
mod query_tests {

use chrono::Duration;
use serde_json::json;
use std::convert::TryFrom;
Expand Down
5 changes: 2 additions & 3 deletions aw-server/src/endpoints/bucket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,8 @@ pub fn bucket_events_get(
Some(dt_str) => match DateTime::parse_from_rfc3339(&dt_str) {
Ok(dt) => Some(dt.with_timezone(&Utc)),
Err(e) => {
let err_msg = format!(
"Failed to parse endtime, datetime needs to be in rfc3339 format: {e}"
);
let err_msg =
format!("Failed to parse endtime, datetime needs to be in rfc3339 format: {e}");
warn!("{}", err_msg);
return Err(HttpErrorJson::new(Status::BadRequest, err_msg));
}
Expand Down
6 changes: 2 additions & 4 deletions aw-sync/tests/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,7 @@ mod sync_tests {
&SyncSpec::default(),
);

let all_datastores: Vec<&Datastore> =
[&state.ds_src, &state.ds_dest].to_vec();
let all_datastores: Vec<&Datastore> = [&state.ds_src, &state.ds_dest].to_vec();
let all_buckets_map = get_all_buckets_map(all_datastores);

// Check that all synced buckets are identical to source bucket
Expand Down Expand Up @@ -190,8 +189,7 @@ mod sync_tests {
&SyncSpec::default(),
);

let all_datastores: Vec<&Datastore> =
[&state.ds_src, &state.ds_dest].to_vec();
let all_datastores: Vec<&Datastore> = [&state.ds_src, &state.ds_dest].to_vec();
let all_buckets_map = get_all_buckets_map(all_datastores);

// Check that all synced buckets are identical to source bucket
Expand Down
3 changes: 1 addition & 2 deletions aw-transform/src/filter_period.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ mod tests {
data: json_map! {"test": json!(1)},
};

let filtered_events =
filter_period_intersect(&vec![e1, e2, e3, e4, e5], &[filter_event]);
let filtered_events = filter_period_intersect(&vec![e1, e2, e3, e4, e5], &[filter_event]);
assert_eq!(filtered_events.len(), 3);
assert_eq!(filtered_events[0].duration, Duration::milliseconds(500));
assert_eq!(filtered_events[1].duration, Duration::milliseconds(1000));
Expand Down

0 comments on commit 7b8b7b3

Please sign in to comment.