Quincunx in the default aspects, sign-based moon phases, backend recalculate command
- 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:
@@ -124,6 +124,7 @@ fn google_token(sub: &str, email: &str, audience: &str) -> String {
|
||||
struct TestApp {
|
||||
router: Router,
|
||||
pool: PgPool,
|
||||
state: Arc<AppState>,
|
||||
}
|
||||
|
||||
struct Response {
|
||||
@@ -141,7 +142,8 @@ impl TestApp {
|
||||
let fake = fake_services().await;
|
||||
let mut config = Config::for_tests(String::new(), fake.clone(), format!("{fake}/jwks"));
|
||||
change(&mut config);
|
||||
Self { router: routes::router(Arc::new(AppState::new(pool.clone(), config))), pool }
|
||||
let state = Arc::new(AppState::new(pool.clone(), config));
|
||||
Self { router: routes::router(state.clone()), pool, state }
|
||||
}
|
||||
|
||||
async fn call(&self, method: &str, uri: &str, token: Option<&str>, body: Option<Value>) -> Response {
|
||||
@@ -1419,3 +1421,42 @@ async fn forecasts_are_free_their_analysis_uses_a_forecast_unit(pool: PgPool) {
|
||||
let (n,): (i64,) = sqlx::query_as("SELECT count(*) FROM forecasts").fetch_one(&pool).await.unwrap();
|
||||
assert_eq!(n, 0);
|
||||
}
|
||||
|
||||
#[sqlx::test(migrator = "db::MIGRATOR")]
|
||||
async fn recalculate_refreshes_calculations_and_queues_every_analysis_again(pool: PgPool) {
|
||||
let app = TestApp::new(pool.clone()).await;
|
||||
let anna = app.register("anna@example.com", "Anna").await;
|
||||
let own = app.chart(&anna, "Saját", true, "1990-03-15").await;
|
||||
let bela = app.chart(&anna, "Béla", false, "1985-08-02").await;
|
||||
let syn = app.post("/v1/synastries", Some(&anna), json!({"chart1_id": own["id"], "chart2_id": bela["id"]})).await;
|
||||
let own_id = own["id"].as_str().unwrap();
|
||||
let forecast = app.post(&format!("/v1/charts/{own_id}/forecasts"), Some(&anna), json!({})).await;
|
||||
assert_eq!(forecast.status, StatusCode::CREATED, "{}", forecast.body);
|
||||
let before = app.get("/v1/me", Some(&anna)).await.body["analyses_left"].clone();
|
||||
// stored with an older calculation
|
||||
sqlx::query("UPDATE charts SET result = '{}', chart_hash = 'old'").execute(&pool).await.unwrap();
|
||||
sqlx::query("UPDATE synastries SET result = '{}', synastry_hash = 'old'").execute(&pool).await.unwrap();
|
||||
sqlx::query("UPDATE forecasts SET result = '{}', forecast_hash = 'old'").execute(&pool).await.unwrap();
|
||||
|
||||
routes::recalculate(&app.state).await.unwrap();
|
||||
|
||||
let (old,): (i64,) = sqlx::query_as(
|
||||
"SELECT (SELECT count(*) FROM charts WHERE chart_hash = 'old' OR result = '{}') \
|
||||
+ (SELECT count(*) FROM synastries WHERE synastry_hash = 'old' OR result = '{}') \
|
||||
+ (SELECT count(*) FROM forecasts WHERE forecast_hash = 'old' OR result = '{}')",
|
||||
)
|
||||
.fetch_one(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(old, 0);
|
||||
let rows: Vec<(String, String, i32)> =
|
||||
sqlx::query_as("SELECT kind, status, credits_charged FROM analyses ORDER BY kind")
|
||||
.fetch_all(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
let kinds: Vec<&str> = rows.iter().map(|r| r.0.as_str()).collect();
|
||||
assert_eq!(kinds, ["forecast", "natal", "natal", "summary", "summary", "synastry"]);
|
||||
assert!(rows.iter().all(|r| r.1 == "pending" && r.2 == 0), "{rows:?}");
|
||||
assert_eq!(app.get("/v1/me", Some(&anna)).await.body["analyses_left"], before);
|
||||
assert_eq!(syn.status, StatusCode::CREATED);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user