Enhance production certificate logic and SQL queries: Updated the QUERY_UPDATE_FALUKANT_USER_CERTIFICATE to include certificate_productions_count_since for tracking production counts since the last level change. Modified the QUERY_GET_PRODUCTION_CERTIFICATE_INPUT_ROWS to filter completed productions based on this timestamp. Improved documentation for clarity on the new logic and its implications for user progression and data retention.
All checks were successful
Deploy yourpart (blue-green) / deploy (push) Successful in 3m12s

This commit is contained in:
Torsten Schulz (local)
2026-04-09 08:13:17 +02:00
parent 731c39dfa4
commit e460792357
4 changed files with 30 additions and 5 deletions

View File

@@ -7,7 +7,7 @@ Implementierung: `src/worker/falukant_certificate.rs` (`run_daily`).
## SQL
- `QUERY_GET_PRODUCTION_CERTIFICATE_INPUT_ROWS` Eingangsdaten je Falukant-User (Spielercharakter, Wissen, Produktionen, Ämter, Haus …)
- `QUERY_UPDATE_FALUKANT_USER_CERTIFICATE` Update der Stufe
- `QUERY_UPDATE_FALUKANT_USER_CERTIFICATE` Stufe + **`certificate_productions_count_since = NOW()`** (Migration `014`)
## Logik (Kurz, Spec §4)
@@ -40,7 +40,11 @@ Rang aus **`political_office_type.name`** (Substring-Heuristik im Daemon, ohne D
## Abgeschlossene Produktionen
**`COUNT(*)`** aus `falukant_log.production` mit `producer_id = falukant_user.id` **oder** `character.id` (Backend kann je nach Kontext die eine oder andere ID schreiben).
**`COUNT(*)`** aus `falukant_log.production` mit `producer_id = falukant_user.id` **oder** `character.id`, und **Zeitstempel** `>= certificate_productions_count_since` (Spalte auf `falukant_user`, Migration **`014_falukant_certificate_productions_count_since.sql`**). **`NULL`** bei dieser Spalte: alle passenden Log-Zeilen (Bestand bis zur ersten Stufenänderung nach Migration).
Bei jedem **Aufstieg**, **Bankrott** (Stufe 1) und **Erbfolge ohne Erben** setzt der Daemon **`certificate_productions_count_since = NOW()`** — die Mindestanforderungen für die **nächste** Stufe gelten damit nur für **neu** abgeschlossene Produktionen. **Logs werden dafür nicht gelöscht** (bleiben u.a. für Wissens-Updates / Preise); optional räumt `QUERY_DELETE_OLD_PRODUCTIONS` nur sehr alte Zeilen auf (aktuell **30 Tage** Retention, Speicherbegrenzung).
**UI:** Dieselbe Filterlogik wie der Daemon verwenden (`>= certificate_productions_count_since`), sonst weichen Anzeige und Aufstieg voneinander ab.
## Gewählter Charakter pro User