Tarot readings have a topic: general, relationship, work, self-knowledge
The new reading form starts with the topic; it steers how the model reads the cards (with the topic's own limits, e.g. no break-up predictions for relationships) and shows on the reading and in the list. Readings from before count as general. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -69,6 +69,8 @@ impl ReadingRow {
|
||||
"status": self.status,
|
||||
"spread": self.tarot["spread"],
|
||||
"spread_name": spread.map(|s| s.name),
|
||||
"topic": tarot::topic(self.tarot["topic"].as_str()).map(|t| t.id),
|
||||
"topic_name": tarot::topic(self.tarot["topic"].as_str()).map(|t| t.name),
|
||||
"question": self.tarot["question"],
|
||||
"cards": cards,
|
||||
"content": self.content,
|
||||
@@ -147,6 +149,8 @@ pub async fn get_one(State(state): St, auth: AuthUser, WithRejection(Path(id), _
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct NewReading {
|
||||
spread: String,
|
||||
/// `general` (the default), `love`, `work` or `self`.
|
||||
topic: Option<String>,
|
||||
question: Option<String>,
|
||||
}
|
||||
|
||||
@@ -157,6 +161,7 @@ pub async fn create(
|
||||
WithRejection(Json(req), _): Body<NewReading>,
|
||||
) -> ApiResult<(StatusCode, Json<Value>)> {
|
||||
let spread = tarot::spread(&req.spread).ok_or_else(|| ApiError::BadRequest("unknown spread".into()))?;
|
||||
let topic = tarot::topic(req.topic.as_deref()).ok_or_else(|| ApiError::BadRequest("unknown topic".into()))?;
|
||||
let question = req.question.map(|q| q.trim().replace("\r\n", "\n")).filter(|q| !q.is_empty());
|
||||
if question.as_ref().is_some_and(|q| q.chars().count() > TAROT_QUESTION_MAX_CHARS) {
|
||||
return Err(ApiError::BadRequest(format!(
|
||||
@@ -179,6 +184,7 @@ pub async fn create(
|
||||
let (sun, moon, ascendant) = big_three(&state, auth.id()).await?;
|
||||
let reading = json!({
|
||||
"spread": spread.id,
|
||||
"topic": topic.id,
|
||||
"question": question,
|
||||
"cards": draw(spread),
|
||||
"sun": sun,
|
||||
|
||||
Reference in New Issue
Block a user