Add heartbeat and null production start fix in ProduceWorker: Implement periodic logging to monitor worker activity and add functionality to update productions with null start timestamps. Enhance SQL queries for better data integrity and debugging capabilities.

This commit is contained in:
Torsten Schulz (local)
2026-01-05 15:30:39 +01:00
parent 108ac6c82b
commit e2630eb32a
2 changed files with 106 additions and 1 deletions

View File

@@ -185,7 +185,18 @@ LIMIT 1;
"#;
pub const QUERY_INSERT_PRODUCTION: &str = r#"
INSERT INTO falukant_data.production (branch_id, product_id, quantity, weather_type_id) VALUES ($1, $2, $3, (SELECT weather_type_id FROM falukant_data.weather WHERE region_id = $4));
INSERT INTO falukant_data.production (branch_id, product_id, quantity, weather_type_id, start_timestamp)
VALUES ($1, $2, $3, (SELECT weather_type_id FROM falukant_data.weather WHERE region_id = $4), NOW());
"#;
// Reparatur: falls Produktionen ohne start_timestamp angelegt wurden, werden sie so gesetzt,
// dass sie sofort als „fertig“ gelten (start = NOW() - production_time Minuten).
pub const QUERY_FIX_NULL_PRODUCTION_START: &str = r#"
UPDATE falukant_data.production p
SET start_timestamp = NOW() - (INTERVAL '1 minute' * pr.production_time)
FROM falukant_type.product pr
WHERE p.start_timestamp IS NULL
AND pr.id = p.product_id;
"#;
// Character creation related queries (missing from earlier extraction)