Famous people: admin page, own prompt, one photo, public pages
CI / test (push) Successful in 2m21s
CI / build (push) Skipped
CI / deploy (push) Skipped

- Admin "Híres emberek": birth data, one photo (S3: DigitalOcean Spaces in
  production, RustFS in development), a face point that every crop keeps
  in view, publishing, and a detailed portrait written with its own
  `celebrity` prompt (third person, by name, from the chart alone).
- The photo is stored once (upright JPEG, at most 2000 px, no metadata);
  next/image makes the sizes from it, so Cloudflare can cache those.
- Public list and pages (/hires-emberek), in the sitemap, with a share
  image showing the face and the chart.
- Share images: the wheel's glyphs and numbers are drawn with the card's
  fonts (inside the SVG image they came out as boxes, on every card).

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-22 16:08:35 +00:00
co-authored by Claude Opus 5.5
parent 13e22a9c7d
commit 37cb0abf4b
47 changed files with 3008 additions and 77 deletions
+15 -2
View File
@@ -117,7 +117,7 @@ pub enum Lane {
/// The short summary of a chart and the tarot readings (questions are
/// claimed separately).
Quick,
/// The detailed analyses and the yearly forecast.
/// The detailed analyses (famous people's too) and the yearly forecast.
Slow,
}
@@ -125,7 +125,7 @@ impl Lane {
fn kinds(self) -> &'static [&'static str] {
match self {
Lane::Quick => &["summary", "tarot"],
Lane::Slow => &["natal", "synastry", "forecast"],
Lane::Slow => &["natal", "synastry", "forecast", "celebrity"],
}
}
}
@@ -187,6 +187,7 @@ impl Analyzer {
let db_err = |e: sqlx::Error| LlmError::Transient(format!("database: {e}"));
let text = match kind {
Kind::Natal | Kind::Summary => self.natal_text(job.chart_id).await?,
Kind::Celebrity => self.celebrity_text(job.chart_id, &job.language).await?,
Kind::Synastry => self.synastry_text(job.synastry_id).await?,
Kind::Forecast => self.forecast_text(job.forecast_id).await?,
Kind::Question => return Err(LlmError::Permanent("a question is not an analysis".into())),
@@ -219,6 +220,17 @@ impl Analyzer {
Ok(compact::natal(&chart))
}
/// A famous person's chart with their name in front.
async fn celebrity_text(&self, chart_id: Option<Uuid>, language: &str) -> Result<String, LlmError> {
let name: String = sqlx::query_scalar("SELECT name FROM celebrities WHERE chart_id = $1")
.bind(chart_id)
.fetch_optional(&self.db)
.await
.map_err(|e| LlmError::Transient(format!("database: {e}")))?
.ok_or_else(|| LlmError::Permanent("the famous person was deleted".into()))?;
Ok(prompt::with_name(language, &name, &self.natal_text(chart_id).await?))
}
/// The compact text of a stored synastry with its two charts.
async fn synastry_text(&self, synastry_id: Option<Uuid>) -> Result<String, LlmError> {
let (result, chart1, chart2): (Value, Value, Value) = sqlx::query_as(
@@ -272,6 +284,7 @@ impl Analyzer {
Kind::Synastry => self.synastry_text(job.synastry_id).await?,
Kind::Forecast => self.forecast_text(job.forecast_id).await?,
Kind::Natal | Kind::Summary => self.natal_text(job.chart_id).await?,
Kind::Celebrity => self.celebrity_text(job.chart_id, &job.language).await?,
Kind::Question => return Err(LlmError::Permanent("a question has no test run".into())),
};
let built = prompt::build(kind, &job.language, &text, Some(&job.system));
+33
View File
@@ -427,6 +427,39 @@ mod analyses {
}
}
#[sqlx::test(migrator = "db::MIGRATOR")]
async fn writes_a_famous_persons_analysis_with_their_name(db: PgPool) {
let s = setup(&db).await;
sqlx::query("UPDATE charts SET kind = 'celebrity', is_primary = false WHERE id = $1")
.bind(s.chart)
.execute(&db)
.await
.unwrap();
sqlx::query("INSERT INTO celebrities (id, chart_id, name, slug) VALUES ($1, $2, 'Teszt Elek', 'teszt-elek')")
.bind(Uuid::now_v7())
.bind(s.chart)
.execute(&db)
.await
.unwrap();
let id = request_analysis(&db, &s).await;
sqlx::query("UPDATE analyses SET kind = 'celebrity', credits_charged = 0 WHERE id = $1")
.bind(id)
.execute(&db)
.await
.unwrap();
let (fake, url) = fake_openrouter(vec![reply(&content(Kind::Celebrity))]).await;
let a = analyzer(&db, &url);
assert!(a.claim(Lane::Quick).await.unwrap().is_none(), "not in the quick lane");
assert!(run_once(&a).await);
assert_eq!(row(&db, id).await.0, "done");
let requests = fake.requests.lock().unwrap();
let system = requests[0]["messages"][0]["content"].as_str().unwrap();
let user = requests[0]["messages"][1]["content"].as_str().unwrap();
assert!(system.contains("harmadik személyben"));
assert!(user.starts_with("Képletadatok:\n\nNév: Teszt Elek\n\n") && user.contains("- Sun: Pisces"));
assert_eq!(requests[0]["response_format"]["json_schema"]["name"], "celebrity_analysis");
}
#[sqlx::test(migrator = "db::MIGRATOR")]
async fn uses_the_admin_edited_system_prompt(db: PgPool) {
let s = setup(&db).await;