v0.14.18
This commit is contained in:
@@ -27,7 +27,7 @@ async fn export_configuration(
|
||||
|
||||
fn validate_configuration_header(export: &ConfigurationExport) -> Result<(), AppError> {
|
||||
if export.format_version != 3 {
|
||||
return Err(AppError::BadRequest("unsupported configuration export version; version 3 is required by GREE Controller 0.14.15".into()));
|
||||
return Err(AppError::BadRequest("unsupported configuration export version; version 3 is required by GREE Controller 0.14.18".into()));
|
||||
}
|
||||
if export.settings.control_strategy != "setpoint" {
|
||||
return Err(AppError::BadRequest(
|
||||
|
||||
+7
-1
@@ -511,6 +511,11 @@ struct PublicCustomChartShare {
|
||||
lang: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct PublicCustomChartQuery {
|
||||
hours: Option<i64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Serialize)]
|
||||
struct PublicChartPoint {
|
||||
timestamp: chrono::DateTime<Utc>,
|
||||
@@ -652,6 +657,7 @@ fn zone_reading_points(rows: Vec<ZoneReading>, field: &str) -> Vec<PublicChartPo
|
||||
async fn public_custom_chart(
|
||||
State(state): State<AppState>,
|
||||
Path(token): Path<String>,
|
||||
Query(query): Query<PublicCustomChartQuery>,
|
||||
) -> Result<Json<Value>, AppError> {
|
||||
if token.len() < 32 || token.len() > 128 || !token.starts_with("chart_") {
|
||||
return Err(AppError::NotFound("custom chart".into()));
|
||||
@@ -663,7 +669,7 @@ async fn public_custom_chart(
|
||||
let share: PublicCustomChartShare = serde_json::from_value(payload)?;
|
||||
validate_public_chart_spec(&share.series)?;
|
||||
|
||||
let hours = share.hours.clamp(1, 24 * 3650);
|
||||
let hours = query.hours.unwrap_or(share.hours).clamp(1, 24 * 3650);
|
||||
let lang = if share.lang == "pl" { "pl" } else { "en" };
|
||||
let since = Utc::now() - ChronoDuration::hours(hours);
|
||||
let bucket_seconds = history_bucket_seconds(hours);
|
||||
|
||||
Reference in New Issue
Block a user