Füge VSCode-Build-Tasks hinzu: Erstelle Aufgaben für den Build-Prozess und Clippy-Überprüfungen.
This commit is contained in:
17
.vscode/tasks.json
vendored
Normal file
17
.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "Build and clippy",
|
||||
"type": "shell",
|
||||
"command": "cargo build && cargo clippy",
|
||||
"group": "build"
|
||||
},
|
||||
{
|
||||
"label": "cargo build",
|
||||
"type": "shell",
|
||||
"command": "cargo build",
|
||||
"group": "build"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1369,9 +1369,9 @@ pub const QUERY_GET_FINISHED_PRODUCTIONS: &str = r#"
|
||||
LEAST(
|
||||
100,
|
||||
(
|
||||
COALESCE(k.knowledge, 0) * 0.6
|
||||
+ COALESCE(k2.knowledge, 0) * 0.3
|
||||
+ COALESCE(pwe.worth_percent, 100) * 0.1
|
||||
(COALESCE(k.knowledge, 0) * 0.75
|
||||
+ COALESCE(k2.knowledge, 0) * 0.25)
|
||||
* COALESCE(pwe.quality_effect, 100) / 100.0
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -1391,9 +1391,12 @@ pub const QUERY_GET_FINISHED_PRODUCTIONS: &str = r#"
|
||||
LEFT JOIN falukant_data.knowledge k2
|
||||
ON k2.character_id = d.director_character_id
|
||||
AND k2.product_id = p.product_id
|
||||
LEFT JOIN falukant_data.weather w
|
||||
ON w.region_id = br.region_id
|
||||
LEFT JOIN falukant_type.product_weather_effect pwe
|
||||
ON pwe.product_id = p.product_id
|
||||
AND pwe.weather_type_id = p.weather_type_id
|
||||
AND pwe.weather_type_id = w.weather_type_id
|
||||
-- Wetter-Effekte derzeit aus der Qualitätsberechnung entfernt
|
||||
WHERE p.start_timestamp + INTERVAL '1 minute' * pr.production_time <= NOW()
|
||||
ORDER BY p.start_timestamp;
|
||||
"#;
|
||||
@@ -1464,8 +1467,8 @@ pub const QUERY_UPDATE_REGION_SELL_PRICE: &str = r#"
|
||||
0,
|
||||
LEAST(
|
||||
CASE
|
||||
WHEN s.quantity > avg_sells THEN tpw.worth_percent - 1
|
||||
WHEN s.quantity < avg_sells THEN tpw.worth_percent + 1
|
||||
WHEN s.quantity > COALESCE(s.avg_sells, 0) * 1.05 THEN tpw.worth_percent + 1
|
||||
WHEN s.quantity < COALESCE(s.avg_sells, 0) * 0.95 THEN tpw.worth_percent - 1
|
||||
ELSE tpw.worth_percent
|
||||
END,
|
||||
100
|
||||
@@ -1499,121 +1502,33 @@ pub const QUERY_GET_SELL_REGIONS: &str = r#"
|
||||
|
||||
pub const QUERY_HOURLY_PRICE_RECALCULATION: &str = r#"
|
||||
WITH city_sales AS (
|
||||
SELECT
|
||||
s.region_id,
|
||||
s.product_id,
|
||||
SUM(s.quantity) AS total_sold
|
||||
SELECT s.region_id, s.product_id, SUM(s.quantity) AS total_sold
|
||||
FROM falukant_log.sell s
|
||||
WHERE s.sell_timestamp >= NOW() - INTERVAL '1 hour'
|
||||
GROUP BY s.region_id, s.product_id
|
||||
),
|
||||
world_avg_sales AS (
|
||||
SELECT
|
||||
product_id,
|
||||
AVG(total_sold) AS avg_sold
|
||||
world_avg AS (
|
||||
SELECT product_id, AVG(total_sold) AS avg_sold
|
||||
FROM city_sales
|
||||
GROUP BY product_id
|
||||
),
|
||||
parent_region_sales AS (
|
||||
SELECT
|
||||
r.parent_region_id,
|
||||
cs.product_id,
|
||||
AVG(cs.total_sold) AS avg_sold
|
||||
FROM city_sales cs
|
||||
JOIN falukant_data.region r ON r.id = cs.region_id
|
||||
WHERE r.parent_region_id IS NOT NULL
|
||||
GROUP BY r.parent_region_id, cs.product_id
|
||||
),
|
||||
price_updates_world AS (
|
||||
adjustments AS (
|
||||
SELECT
|
||||
cs.region_id,
|
||||
cs.product_id,
|
||||
cs.total_sold,
|
||||
COALESCE(wa.avg_sold, 0) AS world_avg,
|
||||
tpw.worth_percent AS current_price,
|
||||
CASE
|
||||
WHEN cs.total_sold > COALESCE(wa.avg_sold, 0) * 1.05
|
||||
THEN tpw.worth_percent * 1.1
|
||||
WHEN cs.total_sold < COALESCE(wa.avg_sold, 0) * 0.95
|
||||
THEN tpw.worth_percent * 0.9
|
||||
ELSE tpw.worth_percent
|
||||
END AS price_after_world
|
||||
WHEN cs.total_sold > COALESCE(wa.avg_sold, 0) * 1.05 THEN 1.10
|
||||
WHEN cs.total_sold < COALESCE(wa.avg_sold, 0) * 0.95 THEN 0.90
|
||||
ELSE 1.00
|
||||
END AS factor
|
||||
FROM city_sales cs
|
||||
JOIN world_avg_sales wa ON wa.product_id = cs.product_id
|
||||
JOIN falukant_data.town_product_worth tpw
|
||||
ON tpw.region_id = cs.region_id
|
||||
AND tpw.product_id = cs.product_id
|
||||
WHERE cs.total_sold > COALESCE(wa.avg_sold, 0) * 1.05
|
||||
OR cs.total_sold < COALESCE(wa.avg_sold, 0) * 0.95
|
||||
),
|
||||
all_cities_with_prices AS (
|
||||
SELECT
|
||||
cs.region_id,
|
||||
cs.product_id,
|
||||
cs.total_sold,
|
||||
r.parent_region_id,
|
||||
tpw.worth_percent AS original_price,
|
||||
COALESCE(puw.price_after_world, tpw.worth_percent) AS price_after_world
|
||||
FROM city_sales cs
|
||||
JOIN falukant_data.region r ON r.id = cs.region_id
|
||||
JOIN falukant_data.town_product_worth tpw
|
||||
ON tpw.region_id = cs.region_id
|
||||
AND tpw.product_id = cs.product_id
|
||||
LEFT JOIN price_updates_world puw
|
||||
ON puw.region_id = cs.region_id
|
||||
AND puw.product_id = cs.product_id
|
||||
),
|
||||
price_updates_parent AS (
|
||||
SELECT
|
||||
acwp.region_id,
|
||||
acwp.product_id,
|
||||
acwp.total_sold,
|
||||
acwp.parent_region_id,
|
||||
COALESCE(prs.avg_sold, 0) AS parent_avg,
|
||||
acwp.price_after_world AS current_price,
|
||||
CASE
|
||||
WHEN acwp.total_sold > COALESCE(prs.avg_sold, 0) * 1.05
|
||||
THEN acwp.price_after_world * 1.05
|
||||
WHEN acwp.total_sold < COALESCE(prs.avg_sold, 0) * 0.95
|
||||
THEN acwp.price_after_world * 0.95
|
||||
ELSE acwp.price_after_world
|
||||
END AS new_price
|
||||
FROM all_cities_with_prices acwp
|
||||
LEFT JOIN parent_region_sales prs
|
||||
ON prs.parent_region_id = acwp.parent_region_id
|
||||
AND prs.product_id = acwp.product_id
|
||||
WHERE acwp.parent_region_id IS NOT NULL
|
||||
AND (
|
||||
acwp.total_sold > COALESCE(prs.avg_sold, 0) * 1.05
|
||||
OR acwp.total_sold < COALESCE(prs.avg_sold, 0) * 0.95
|
||||
)
|
||||
),
|
||||
final_price_updates AS (
|
||||
SELECT
|
||||
COALESCE(pup.region_id, puw.region_id) AS region_id,
|
||||
COALESCE(pup.product_id, puw.product_id) AS product_id,
|
||||
COALESCE(pup.new_price, puw.price_after_world, acwp.original_price) AS final_price
|
||||
FROM all_cities_with_prices acwp
|
||||
LEFT JOIN price_updates_world puw
|
||||
ON puw.region_id = acwp.region_id
|
||||
AND puw.product_id = acwp.product_id
|
||||
LEFT JOIN price_updates_parent pup
|
||||
ON pup.region_id = acwp.region_id
|
||||
AND pup.product_id = acwp.product_id
|
||||
WHERE puw.region_id IS NOT NULL
|
||||
OR pup.region_id IS NOT NULL
|
||||
JOIN world_avg wa ON wa.product_id = cs.product_id
|
||||
)
|
||||
UPDATE falukant_data.town_product_worth tpw
|
||||
SET worth_percent = GREATEST(
|
||||
0,
|
||||
LEAST(
|
||||
100,
|
||||
fpu.final_price
|
||||
)
|
||||
)
|
||||
FROM final_price_updates fpu
|
||||
WHERE tpw.region_id = fpu.region_id
|
||||
AND tpw.product_id = fpu.product_id;
|
||||
SET worth_percent = GREATEST(0, LEAST(100, tpw.worth_percent * adj.factor))
|
||||
FROM adjustments adj
|
||||
WHERE tpw.region_id = adj.region_id
|
||||
AND tpw.product_id = adj.product_id;
|
||||
"#;
|
||||
|
||||
pub const QUERY_SET_MARRIAGES_BY_PARTY: &str = r#"
|
||||
|
||||
Reference in New Issue
Block a user