Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: added query function in aw-client #477

Merged
merged 3 commits into from
Apr 5, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: fixed client query
  • Loading branch information
ErikBjare committed Apr 5, 2024
commit ae603a2336fc8ea3cd73ea75640591dd3d7073ba
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
@@ -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()
16 changes: 16 additions & 0 deletions aw-client-rust/tests/test.rs
Original file line number Diff line number Diff line change
@@ -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();
Loading