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
+16 -7
View File
@@ -1,6 +1,9 @@
//! Natal charts of a user: their own chart (kind `own`; the current one is
//! primary) and charts of other people they added (kind `person`, see
//! [`crate::persons`]). Calculated by the horoscope service.
//!
//! Famous people's charts (kind `celebrity`) are kept by the admin pages
//! (see `celebrities`): these routes neither list nor change them.
use axum::Json;
use axum::extract::State;
@@ -26,7 +29,7 @@ pub struct ChartRow {
pub owner_id: Uuid,
pub label: String,
pub is_primary: bool,
/// `own` or `person`.
/// `own`, `person` or `celebrity`.
pub kind: String,
pub birth_data: Value,
pub result: Value,
@@ -83,9 +86,12 @@ pub async fn find_chart(db: impl PgExecutor<'_>, id: Uuid) -> Result<Option<Char
Ok(sqlx::query_as(&format!("SELECT {CHART_COLUMNS} FROM charts WHERE id = $1")).bind(id).fetch_optional(db).await?)
}
/// A chart of `owner`; 404 for missing charts and charts of others.
/// A chart of `owner`; 404 for missing charts, charts of others and famous people's charts.
pub async fn owned_chart(db: &PgPool, id: Uuid, owner: Uuid) -> Result<ChartRow, ApiError> {
find_chart(db, id).await?.filter(|c| c.owner_id == owner).ok_or(ApiError::NotFound("chart"))
find_chart(db, id)
.await?
.filter(|c| c.owner_id == owner && c.kind != "celebrity")
.ok_or(ApiError::NotFound("chart"))
}
pub async fn primary_chart(db: &PgPool, owner: Uuid) -> Result<Option<ChartRow>, ApiError> {
@@ -102,7 +108,8 @@ fn clean_label(label: &str) -> Result<String, ApiError> {
pub async fn list(State(state): St, auth: AuthUser) -> ApiResult<Json<Value>> {
let rows: Vec<ChartRow> = sqlx::query_as(&format!(
"SELECT {CHART_COLUMNS} FROM charts WHERE owner_id = $1 ORDER BY is_primary DESC, created_at DESC"
"SELECT {CHART_COLUMNS} FROM charts WHERE owner_id = $1 AND kind <> 'celebrity' \
ORDER BY is_primary DESC, created_at DESC"
))
.bind(auth.id())
.fetch_all(&state.db)
@@ -190,8 +197,10 @@ pub async fn create(
queue_summary(&state, &auth, &chart).await;
return Ok((StatusCode::OK, Json(chart.owner_view())));
}
let (count,): (i64,) =
sqlx::query_as("SELECT count(*) FROM charts WHERE owner_id = $1").bind(auth.id()).fetch_one(&state.db).await?;
let (count,): (i64,) = sqlx::query_as("SELECT count(*) FROM charts WHERE owner_id = $1 AND kind <> 'celebrity'")
.bind(auth.id())
.fetch_one(&state.db)
.await?;
if count >= state.config.max_charts_per_user {
return Err(ApiError::conflict(
"chart_limit_reached",
@@ -372,7 +381,7 @@ pub async fn remove(
auth: AuthUser,
WithRejection(axum::extract::Path(id), _): IdPath,
) -> ApiResult<StatusCode> {
let result = sqlx::query("DELETE FROM charts WHERE id = $1 AND owner_id = $2")
let result = sqlx::query("DELETE FROM charts WHERE id = $1 AND owner_id = $2 AND kind <> 'celebrity'")
.bind(id)
.bind(auth.id())
.execute(&state.db)