Questions about relationship analyses too
- The answer sees both charts and the comparison; both people see the questions - Heading, hint and example question per analysis kind Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
//! Questions about a finished detailed analysis: a natal chart analysis or a
|
||||
//! yearly forecast. Each question uses a `question` unit (admins ask for
|
||||
//! Questions about a finished detailed analysis: a natal chart analysis, a
|
||||
//! relationship (synastry) analysis or a yearly forecast. On a comparison both
|
||||
//! people see the questions and answers. Each question uses a `question` unit (admins ask for
|
||||
//! free). The worker answers with the question model of the admin page,
|
||||
//! seeing the chart data, the analysis and the earlier questions about it.
|
||||
|
||||
@@ -23,7 +24,7 @@ use crate::error::{ApiError, ApiResult};
|
||||
use crate::views::{rfc3339, rfc3339_opt};
|
||||
|
||||
/// The analyses that can be asked about.
|
||||
const ASKABLE: [&str; 2] = ["natal", "forecast"];
|
||||
const ASKABLE: [&str; 3] = ["natal", "synastry", "forecast"];
|
||||
/// A safety cap per analysis.
|
||||
const MAX_PER_ANALYSIS: i64 = 100;
|
||||
|
||||
@@ -115,7 +116,7 @@ pub async fn ask(
|
||||
return Err(ApiError::NotFound("analysis"));
|
||||
}
|
||||
if !ASKABLE.contains(&analysis.kind.as_str()) {
|
||||
return Err(ApiError::BadRequest("questions can be asked about a natal analysis or a forecast".into()));
|
||||
return Err(ApiError::BadRequest("questions can be asked about a detailed analysis or a forecast".into()));
|
||||
}
|
||||
if analysis.status != "done" {
|
||||
return Err(ApiError::conflict("analysis_not_ready", "Az elemzés még nem készült el."));
|
||||
|
||||
@@ -761,6 +761,18 @@ async fn synastry_analyses_use_synastry_units(pool: PgPool) {
|
||||
app.get("/v1/credits", Some(&anna)).await.body["balance"],
|
||||
json!({"natal": 1, "synastry": 0, "forecast": 0, "question": 0})
|
||||
);
|
||||
|
||||
// questions can be asked about the relationship analysis too
|
||||
let analysis = r.body["id"].as_str().unwrap().to_string();
|
||||
sqlx::query("UPDATE analyses SET status = 'done', content = '{\"title\": \"Kettőtök\"}' WHERE kind = 'synastry'")
|
||||
.execute(&app.pool)
|
||||
.await
|
||||
.unwrap();
|
||||
grant_units(&app, &anna, "question", 1).await;
|
||||
let r = app
|
||||
.post(&format!("/v1/analyses/{analysis}/questions"), Some(&anna), json!({"question": "Mire figyeljünk?"}))
|
||||
.await;
|
||||
assert_eq!((r.status, r.body["status"].as_str()), (StatusCode::ACCEPTED, Some("pending")), "{}", r.body);
|
||||
}
|
||||
|
||||
#[sqlx::test(migrator = "db::MIGRATOR")]
|
||||
|
||||
Reference in New Issue
Block a user