Enhance production certificate logic and event handling: Updated the daily recalculation process in FalukantFamilyWorker to decouple it from family migration, ensuring consistent execution. Introduced a new mechanism to reset certificates upon succession without heirs, improving user experience. Refined SQL queries for better data retrieval and event publishing, including distinct character selection logic. Enhanced documentation for clarity on the updated processes and their implications.
All checks were successful
Deploy yourpart (blue-green) / deploy (push) Successful in 2m55s
All checks were successful
Deploy yourpart (blue-green) / deploy (push) Successful in 2m55s
This commit is contained in:
@@ -3471,7 +3471,8 @@ pub const QUERY_INSERT_CHILD_RELATION_LOVER: &str = r#"
|
||||
|
||||
// --- Produktionszertifikat (Daemon Daily, Spec: Produktionszertifikate) ---
|
||||
|
||||
/// Ein Spielercharakter pro Falukant-User (niedrigste character.id bei mehreren lebenden).
|
||||
/// Ein Spielercharakter pro Falukant-User (bei mehreren lebenden: **höchste** `character.id`,
|
||||
/// typischerweise zuletzt aktiver Slot — konsistent mit UI, das oft den Hauptcharakter nutzt).
|
||||
pub const QUERY_GET_PRODUCTION_CERTIFICATE_INPUT_ROWS: &str = r#"
|
||||
SELECT DISTINCT ON (fu.id)
|
||||
fu.id AS falukant_user_id,
|
||||
@@ -3490,6 +3491,7 @@ pub const QUERY_GET_PRODUCTION_CERTIFICATE_INPUT_ROWS: &str = r#"
|
||||
SELECT COUNT(*)::bigint
|
||||
FROM falukant_log.production pl
|
||||
WHERE pl.producer_id = fu.id
|
||||
OR pl.producer_id = c.id
|
||||
), 0) AS completed_production_count,
|
||||
COALESCE((
|
||||
SELECT MAX(cot.hierarchy_level)::int
|
||||
@@ -3515,7 +3517,7 @@ pub const QUERY_GET_PRODUCTION_CERTIFICATE_INPUT_ROWS: &str = r#"
|
||||
FROM falukant_data.falukant_user fu
|
||||
JOIN falukant_data.character c ON c.user_id = fu.id AND c.health > 0
|
||||
LEFT JOIN falukant_type.title t ON t.id = c.title_of_nobility
|
||||
ORDER BY fu.id, c.id;
|
||||
ORDER BY fu.id, c.id DESC;
|
||||
"#;
|
||||
|
||||
pub const QUERY_UPDATE_FALUKANT_USER_CERTIFICATE: &str = r#"
|
||||
@@ -3525,3 +3527,11 @@ pub const QUERY_UPDATE_FALUKANT_USER_CERTIFICATE: &str = r#"
|
||||
WHERE id = $2::int;
|
||||
"#;
|
||||
|
||||
/// Zertifikat + `event_user_id` für WebSocket (`COALESCE(user_id, id)` wie bei `QUERY_GET_PRODUCTION_CERTIFICATE_INPUT_ROWS`).
|
||||
pub const QUERY_GET_FALUKANT_USER_CERT_AND_EVENT: &str = r#"
|
||||
SELECT COALESCE(certificate, 1)::int AS certificate,
|
||||
COALESCE(user_id, id)::int AS event_user_id
|
||||
FROM falukant_data.falukant_user
|
||||
WHERE id = $1::int;
|
||||
"#;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user