Persons: other people's charts with package slots, list page, switcher
CI / test (push) Failing after 43s
CI / build (push) Skipped
CI / deploy (push) Skipped

- charts.kind own/person; a new person uses a 'person' unit (not refunded
  on delete); person packages and an unlimited entitlement; admins unlimited
- a person's birth data can be corrected within an hour (admins any time)
- /kepletek list with tiles, /kepletek/uj, correction page, mock person
  packages, chart page title switches between charts keeping the tab

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-17 11:03:55 +00:00
co-authored by Claude Opus 5.5
parent 50875c0006
commit fef1605848
28 changed files with 1008 additions and 54 deletions
+10 -3
View File
@@ -14,6 +14,8 @@ use crate::error::ApiError;
pub enum Unit {
Natal,
Synastry,
/// A slot for adding a person (see [`crate::persons`]).
Person,
}
impl Unit {
@@ -21,6 +23,7 @@ impl Unit {
match self {
Unit::Natal => "natal",
Unit::Synastry => "synastry",
Unit::Person => "person",
}
}
}
@@ -30,6 +33,8 @@ impl Unit {
pub struct Balance {
pub natal: i64,
pub synastry: i64,
/// Bought person slots (not the slots left; see [`crate::persons::slots`]).
pub person: i64,
}
impl Balance {
@@ -37,6 +42,7 @@ impl Balance {
match unit {
Unit::Natal => self.natal,
Unit::Synastry => self.synastry,
Unit::Person => self.person,
}
}
@@ -46,15 +52,16 @@ impl Balance {
}
pub async fn balance(conn: &mut PgConnection, user_id: Uuid) -> Result<Balance, ApiError> {
let (natal, synastry): (i64, i64) = sqlx::query_as(
let (natal, synastry, person): (i64, i64, i64) = sqlx::query_as(
"SELECT COALESCE(SUM(delta) FILTER (WHERE unit = 'natal'), 0)::bigint, \
COALESCE(SUM(delta) FILTER (WHERE unit = 'synastry'), 0)::bigint \
COALESCE(SUM(delta) FILTER (WHERE unit = 'synastry'), 0)::bigint, \
COALESCE(SUM(delta) FILTER (WHERE unit = 'person' AND reason <> 'person'), 0)::bigint \
FROM credit_ledger WHERE user_id = $1",
)
.bind(user_id)
.fetch_one(conn)
.await?;
Ok(Balance { natal, synastry })
Ok(Balance { natal, synastry, person })
}
/// Spends one unit inside the caller's transaction. The user row is locked