Forum: the attached chart's wheel in the question
A question with a shared chart shows the chart's wheel, one with a shared synastry the two charts on one wheel, at a fixed size beside the details (above them on phones). The forum sends the wheel's data (positions, angles, houses, aspects; never birth date, time or place) to logged-in members only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -26,6 +26,10 @@ struct CardRow {
|
||||
natal: Option<Value>,
|
||||
year: Option<i32>,
|
||||
summary_title: Option<String>,
|
||||
/// A synastry: the two charts and the aspects between them.
|
||||
chart1: Option<Value>,
|
||||
chart2: Option<Value>,
|
||||
pair_aspects: Option<Value>,
|
||||
}
|
||||
|
||||
const CARD_SELECT: &str = "SELECT s.id, s.slug, s.kind, s.revoked_at IS NOT NULL AS revoked, \
|
||||
@@ -35,11 +39,15 @@ const CARD_SELECT: &str = "SELECT s.id, s.slug, s.kind, s.revoked_at IS NOT NULL
|
||||
AND a.kind = 'summary' AND a.status = 'done' ORDER BY a.completed_at DESC LIMIT 1) \
|
||||
WHEN 'forecast' THEN (SELECT a.content->>'title' FROM analyses a WHERE a.forecast_id = s.forecast_id \
|
||||
AND a.kind = 'forecast' AND a.status = 'done' ORDER BY a.completed_at DESC LIMIT 1) \
|
||||
END AS summary_title \
|
||||
END AS summary_title, \
|
||||
c1.result AS chart1, c2.result AS chart2, sy.result->'aspects' AS pair_aspects \
|
||||
FROM shares s \
|
||||
LEFT JOIN charts c ON c.id = s.chart_id \
|
||||
LEFT JOIN forecasts f ON f.id = s.forecast_id \
|
||||
LEFT JOIN charts fc ON fc.id = f.chart_id";
|
||||
LEFT JOIN charts fc ON fc.id = f.chart_id \
|
||||
LEFT JOIN synastries sy ON sy.id = s.synastry_id \
|
||||
LEFT JOIN charts c1 ON c1.id = sy.chart1_id \
|
||||
LEFT JOIN charts c2 ON c2.id = sy.chart2_id";
|
||||
|
||||
/// Sun, Moon and (with a known birth time) the Ascendant: sign, degree, house.
|
||||
fn big_three(natal: &Value) -> (Vec<Value>, bool) {
|
||||
@@ -68,6 +76,21 @@ fn big_three(natal: &Value) -> (Vec<Value>, bool) {
|
||||
(points, time_known)
|
||||
}
|
||||
|
||||
/// What the wheel is drawn from: the positions, angles, houses and aspects
|
||||
/// (never the birth date, time or place).
|
||||
fn wheel(chart: &Value) -> Value {
|
||||
json!({
|
||||
"points": chart["points"],
|
||||
"angles": chart["angles"],
|
||||
"houses": chart["houses"],
|
||||
"aspects": chart["aspects"],
|
||||
})
|
||||
}
|
||||
|
||||
fn time_known(chart: &Value) -> bool {
|
||||
chart.pointer("/time/time_known").and_then(Value::as_bool).unwrap_or(false)
|
||||
}
|
||||
|
||||
fn card(row: &CardRow) -> Value {
|
||||
if row.revoked {
|
||||
return json!({ "slug": row.slug, "kind": row.kind, "revoked": true });
|
||||
@@ -77,7 +100,22 @@ fn card(row: &CardRow) -> Value {
|
||||
("forecast", Some(year)) => format!("Éves előrejelzés · {year}–{}", year + 1),
|
||||
_ => "Születési képlet".to_string(),
|
||||
};
|
||||
let (points, time_known) = row.natal.as_ref().map(big_three).unwrap_or_default();
|
||||
let (points, known) = row.natal.as_ref().map(big_three).unwrap_or_default();
|
||||
// The drawing itself: the chart's wheel, or the two charts on one wheel.
|
||||
let chart = match (row.kind.as_str(), &row.natal) {
|
||||
("chart", Some(natal)) => wheel(natal),
|
||||
_ => Value::Null,
|
||||
};
|
||||
let pair = match (&row.chart1, &row.chart2) {
|
||||
(Some(a), Some(b)) if row.kind == "synastry" => json!({
|
||||
"chart1": wheel(a),
|
||||
"chart2": wheel(b),
|
||||
"time1": time_known(a),
|
||||
"time2": time_known(b),
|
||||
"aspects": row.pair_aspects.clone().unwrap_or(Value::Array(Vec::new())),
|
||||
}),
|
||||
_ => Value::Null,
|
||||
};
|
||||
json!({
|
||||
"slug": row.slug,
|
||||
"kind": row.kind,
|
||||
@@ -85,7 +123,9 @@ fn card(row: &CardRow) -> Value {
|
||||
"title": title,
|
||||
"summary": row.summary_title,
|
||||
"points": points,
|
||||
"time_known": time_known,
|
||||
"time_known": known,
|
||||
"chart": chart,
|
||||
"pair": pair,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -1261,6 +1261,8 @@ async fn a_question_about_ones_chart(pool: PgPool) {
|
||||
assert_eq!(preview["title"], "Születési képlet");
|
||||
assert_eq!(preview["points"][0], json!({"id": "sun", "sign": "leo", "degree": 12, "house": 10}));
|
||||
assert_eq!(preview["points"][2]["id"], "ascendant");
|
||||
assert_eq!(preview["chart"]["points"][1]["sign"], "pisces", "the wheel's data");
|
||||
assert!(preview["chart"].get("time").is_none(), "no birth time");
|
||||
assert!(!preview.to_string().contains("Kovács"), "no names");
|
||||
for (slug, who) in [("annaplain000001", &anna), ("annaforum000001", &bea), ("nincsilyen", &anna)] {
|
||||
let (status, _) = app.call("GET", &format!("/v1/forum/share-card/{slug}"), Some(who), Value::Null).await;
|
||||
|
||||
Reference in New Issue
Block a user