Skip to content

Commit

Permalink
Make end_date optional for hourly energy usage route
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementNerma committed Dec 1, 2024
1 parent cc998c7 commit aec120f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion 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 Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tapo-rest"
version = "0.2.0"
version = "0.2.1"
edition = "2021"

[dependencies]
Expand Down
4 changes: 3 additions & 1 deletion src/server/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,9 @@ routes! {
Ok(Json(client.get_energy_usage().await?))
}

async fn get_hourly_energy_data(&state, &client, start_date: NaiveDate, end_date: NaiveDate) -> Json<EnergyDataResult> {
async fn get_hourly_energy_data(&state, &client, start_date: NaiveDate, end_date: Option<NaiveDate>) -> Json<EnergyDataResult> {
let end_date = end_date.unwrap_or(start_date);

Ok(Json(client.get_energy_data(EnergyDataInterval::Hourly { start_date, end_date }).await?))
}

Expand Down

0 comments on commit aec120f

Please sign in to comment.