Update production log SQL queries to include completion count: Modified the QUERY_INSERT_UPDATE_PRODUCTION_LOG to add a new completion_count field, ensuring accurate tracking of completed productions. Updated related documentation to reflect changes in production counting logic and SQL migrations.
All checks were successful
Deploy yourpart (blue-green) / deploy (push) Successful in 1m51s

This commit is contained in:
Torsten Schulz (local)
2026-04-17 16:59:22 +02:00
parent 48d8e9b293
commit 75a1e5b306
5 changed files with 33 additions and 9 deletions

View File

@@ -2640,11 +2640,13 @@ pub const QUERY_INSERT_UPDATE_PRODUCTION_LOG: &str = r#"
product_id,
quantity,
producer_id,
production_date
) VALUES ($1, $2, $3, $4, CURRENT_DATE)
production_date,
completion_count
) VALUES ($1, $2, $3, $4, CURRENT_DATE, 1)
ON CONFLICT (producer_id, product_id, region_id, production_date)
DO UPDATE
SET quantity = falukant_log.production.quantity + EXCLUDED.quantity;
SET quantity = falukant_log.production.quantity + EXCLUDED.quantity,
completion_count = falukant_log.production.completion_count + 1;
"#;
pub const QUERY_ADD_OVERPRODUCTION_NOTIFICATION: &str = r#"
@@ -3900,7 +3902,7 @@ pub const QUERY_HAS_MOTHER_BIRTH_TODAY: &str = r#"
/// Ein Spielercharakter pro Falukant-User (bei mehreren lebenden: **höchste** `character.id`,
/// typischerweise zuletzt aktiver Slot — konsistent mit UI, das oft den Hauptcharakter nutzt).
/// `completed_production_count`: Produktionen seit `certificate_productions_count_since` (Migration `014`); **NULL** = alle Log-Zeilen (Bestand vor erstem Aufstieg nach Migration).
/// `completed_production_count`: Summe `completion_count` in `falukant_log.production` seit `certificate_productions_count_since` (Migration `014`; Spalte `completion_count` Migration `015`); **NULL** = alle passenden Log-Zeilen (Bestand vor erstem Aufstieg nach Migration).
pub const QUERY_GET_PRODUCTION_CERTIFICATE_INPUT_ROWS: &str = r#"
SELECT DISTINCT ON (fu.id)
fu.id AS falukant_user_id,
@@ -3916,7 +3918,7 @@ pub const QUERY_GET_PRODUCTION_CERTIFICATE_INPUT_ROWS: &str = r#"
WHERE k.character_id = c.id
), 0.0) AS avg_knowledge,
COALESCE((
SELECT COUNT(*)::bigint
SELECT SUM(pl.completion_count)::bigint
FROM falukant_log.production pl
WHERE (pl.producer_id = fu.id OR pl.producer_id = c.id)
AND (