Quincunx in the default aspects, sign-based moon phases, backend recalculate command
CI / test (push) Successful in 55s
CI / build (push) Successful in 5m14s
CI / deploy (push) Skipped

- AspectSet::Standard (default): the major aspects and the quincunx; forecasts use it too
- Moon phase: new, quarter and full moon only within 12° and in the matching signs
- backend recalculate: recalculates stored charts, comparisons and forecasts,
  then queues every analysis again (nobody is charged)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
feco
2026-11-18 12:18:39 +00:00
co-authored by Claude Opus 5.5
parent 62df5c2764
commit 23975a8369
15 changed files with 280 additions and 38 deletions
+22 -9
View File
@@ -19,6 +19,7 @@ use uuid::Uuid;
use super::charts::{ChartRow, find_chart, owned_chart};
use super::{Body, IdPath, St};
use crate::AppState;
use crate::auth::AuthUser;
use crate::error::{ApiError, ApiResult};
use crate::views::{rfc3339, sha256_hex};
@@ -224,15 +225,7 @@ pub async fn create(
));
}
let mut request = json!({ "birth": chart.birth_data, "year": year });
if let Some(l) = &location {
request["location"] = l.clone();
}
let mut result = state.horoscope.forecast(&request).await?;
if let Some(obj) = result.as_object_mut() {
obj.remove("meta");
}
let forecast_hash = forecast_hash(&chart.chart_hash, year, &location_key, &result);
let (result, forecast_hash) = calculate(&state, &chart, year, location.as_ref(), &location_key).await?;
let row: ForecastRow = sqlx::query_as(&format!(
"INSERT INTO forecasts (id, chart_id, chart_hash, year, location, location_key, result, forecast_hash, created_by) \
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) \
@@ -253,6 +246,26 @@ pub async fn create(
Ok((StatusCode::CREATED, Json(row.view())))
}
/// One year of a stored chart as stored: `(result, forecast_hash)`.
pub(super) async fn calculate(
state: &AppState,
chart: &ChartRow,
year: i32,
location: Option<&Value>,
location_key: &str,
) -> Result<(Value, String), ApiError> {
let mut request = json!({ "birth": chart.birth_data, "year": year });
if let Some(l) = location {
request["location"] = l.clone();
}
let mut result = state.horoscope.forecast(&request).await?;
if let Some(obj) = result.as_object_mut() {
obj.remove("meta");
}
let hash = forecast_hash(&chart.chart_hash, year, location_key, &result);
Ok((result, hash))
}
/// Identifies a forecast independently of how the place was entered: the
/// chart, the year and the resolved place and time zone of the solar return.
fn forecast_hash(chart_hash: &str, year: i32, location_key: &str, result: &Value) -> String {