Add SQL query for product price history: Introduced a new query to insert regional product prices into the history table, calculating prices based on sell cost and worth percentage. Updated ValueRecalculationWorker to log current prices for affected regions, enhancing price tracking functionality.
This commit is contained in:
@@ -1607,6 +1607,20 @@ pub const QUERY_HOURLY_PRICE_RECALCULATION: &str = r#"
|
||||
AND tpw.product_id = adj.product_id;
|
||||
"#;
|
||||
|
||||
/// Fügt für eine Region Preise in die Historie ein.
|
||||
/// Berechnet den regionalen Produktpreis als sell_cost * worth_percent / 100.
|
||||
pub const QUERY_INSERT_PRODUCT_PRICE_HISTORY: &str = r#"
|
||||
INSERT INTO falukant_log.product_price_history (product_id, region_id, price, recorded_at)
|
||||
SELECT
|
||||
tpw.product_id,
|
||||
tpw.region_id,
|
||||
ROUND(ftp.sell_cost * tpw.worth_percent / 100.0, 2) AS price,
|
||||
NOW() AS recorded_at
|
||||
FROM falukant_data.town_product_worth tpw
|
||||
JOIN falukant_type.product ftp ON ftp.id = tpw.product_id
|
||||
WHERE tpw.region_id = $1;
|
||||
"#;
|
||||
|
||||
pub const QUERY_SET_MARRIAGES_BY_PARTY: &str = r#"
|
||||
WITH updated_relations AS (
|
||||
UPDATE falukant_data.relationship AS rel
|
||||
|
||||
Reference in New Issue
Block a user