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
All checks were successful
Deploy yourpart (blue-green) / deploy (push) Successful in 3m12s
This commit is contained in:
@@ -2518,9 +2518,11 @@ pub const QUERY_UPDATE_PRODUCT_KNOWLEDGE_USER: &str = r#"
|
||||
AND k.product_id = 10;
|
||||
"#;
|
||||
|
||||
/// Aufräumen alter Log-Zeilen (Speicher); Zertifikats-Mindest-Produktionen seit Aufstieg siehe
|
||||
/// `certificate_productions_count_since` — kein „Reset“ über Löschen nötig.
|
||||
pub const QUERY_DELETE_OLD_PRODUCTIONS: &str = r#"
|
||||
DELETE FROM falukant_log.production flp
|
||||
WHERE DATE(flp.production_timestamp) < CURRENT_DATE;
|
||||
WHERE DATE(flp.production_timestamp) < CURRENT_DATE - INTERVAL '30 days';
|
||||
"#;
|
||||
|
||||
pub const QUERY_GET_PRODUCERS_LAST_DAY: &str = r#"
|
||||
@@ -3691,6 +3693,7 @@ pub const QUERY_INSERT_CHILD_RELATION_LOVER: &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).
|
||||
pub const QUERY_GET_PRODUCTION_CERTIFICATE_INPUT_ROWS: &str = r#"
|
||||
SELECT DISTINCT ON (fu.id)
|
||||
fu.id AS falukant_user_id,
|
||||
@@ -3708,8 +3711,14 @@ pub const QUERY_GET_PRODUCTION_CERTIFICATE_INPUT_ROWS: &str = r#"
|
||||
COALESCE((
|
||||
SELECT COUNT(*)::bigint
|
||||
FROM falukant_log.production pl
|
||||
WHERE pl.producer_id = fu.id
|
||||
OR pl.producer_id = c.id
|
||||
WHERE (pl.producer_id = fu.id OR pl.producer_id = c.id)
|
||||
AND (
|
||||
fu.certificate_productions_count_since IS NULL
|
||||
OR COALESCE(
|
||||
pl.production_timestamp,
|
||||
pl.production_date::timestamp
|
||||
) >= fu.certificate_productions_count_since
|
||||
)
|
||||
), 0) AS completed_production_count,
|
||||
COALESCE((
|
||||
SELECT MAX(cot.hierarchy_level)::int
|
||||
@@ -3738,9 +3747,11 @@ pub const QUERY_GET_PRODUCTION_CERTIFICATE_INPUT_ROWS: &str = r#"
|
||||
ORDER BY fu.id, c.id DESC;
|
||||
"#;
|
||||
|
||||
/// Setzt bei jeder Stufenänderung `certificate_productions_count_since` (Mindest-Produktionen / PP neu ab Aufstieg).
|
||||
pub const QUERY_UPDATE_FALUKANT_USER_CERTIFICATE: &str = r#"
|
||||
UPDATE falukant_data.falukant_user
|
||||
SET certificate = $1::int,
|
||||
certificate_productions_count_since = NOW(),
|
||||
updated_at = NOW()
|
||||
WHERE id = $2::int;
|
||||
"#;
|
||||
|
||||
Reference in New Issue
Block a user