Skip to content

Commit

Permalink
fix: fixed client query
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare committed Apr 5, 2024
1 parent 9416fe0 commit ae603a2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion aw-client-rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ impl AwClient {
self.client
.post(url)
.json(&json!({
"query": query,
"query": query.split('\n').collect::<Vec<&str>>(),
"timeperiods": timeperiods_str,
}))
.send()
Expand Down
16 changes: 16 additions & 0 deletions aw-client-rust/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,22 @@ mod test {
println!("Events: {events:?}");
assert!(events[0].duration == Duration::seconds(1));

// Query
let query = format!(
"events = query_bucket(\"{}\");
RETURN = events;",
bucket.id
);
let start: DateTime<Utc> = DateTime::parse_from_rfc3339("1996-12-19T00:00:00-08:00")
.unwrap()
.into();
let end: DateTime<Utc> = DateTime::parse_from_rfc3339("2020-12-19T00:00:00-08:00")
.unwrap()
.into();
let timeperiods = (start, end);
let query_result = client.query(&query, vec![timeperiods]).unwrap();
println!("Query result: {query_result:?}");

client
.delete_event(&bucketname, events[0].id.unwrap())
.unwrap();
Expand Down

0 comments on commit ae603a2

Please sign in to comment.