Füge neue SQL-Abfragen für die Abfrage von Lagerbeständen nach Typ hinzu: Implementiere QUERY_GET_REGION_STOCKS_BY_TYPE und QUERY_GET_USER_STOCKS_BY_TYPE, um die Abfrage von Lagerbeständen zu optimieren. Aktualisiere die Logik in events.rs, um die neuen Abfragen zu verwenden und erweitere die Struktur StorageDamageInfo, um zusätzliche Informationen zu zerstörten Einheiten und betroffenen Regionen zu speichern. Ergänze die Dokumentation in AGENTS.md mit Projektleitlinien und Entwicklungsbefehlen.
All checks were successful
Deploy yourpart (blue-green) / deploy (push) Successful in 1m48s
All checks were successful
Deploy yourpart (blue-green) / deploy (push) Successful in 1m48s
This commit is contained in:
@@ -753,9 +753,12 @@ UPDATE falukant_data.inventory SET quantity = $1 WHERE id = $2;
|
||||
"#;
|
||||
|
||||
pub const QUERY_GET_USER_STOCKS: &str = r#"
|
||||
SELECT s.id AS stock_id, s.quantity AS current_capacity
|
||||
SELECT s.id AS stock_id,
|
||||
s.quantity AS current_capacity,
|
||||
st.label_tr AS stock_type_label
|
||||
FROM falukant_data.stock s
|
||||
JOIN falukant_data.branch b ON s.branch_id = b.id
|
||||
LEFT JOIN falukant_type.stock st ON st.id = s.stock_type_id
|
||||
WHERE b.falukant_user_id = $1;
|
||||
"#;
|
||||
|
||||
@@ -766,9 +769,12 @@ UPDATE falukant_data.stock
|
||||
"#;
|
||||
|
||||
pub const QUERY_GET_REGION_STOCKS: &str = r#"
|
||||
SELECT s.id AS stock_id, s.quantity AS current_capacity
|
||||
SELECT s.id AS stock_id,
|
||||
s.quantity AS current_capacity,
|
||||
st.label_tr AS stock_type_label
|
||||
FROM falukant_data.stock s
|
||||
JOIN falukant_data.branch b ON s.branch_id = b.id
|
||||
LEFT JOIN falukant_type.stock st ON st.id = s.stock_type_id
|
||||
WHERE b.region_id = $1;
|
||||
"#;
|
||||
|
||||
@@ -2699,6 +2705,18 @@ pub const QUERY_GET_INVENTORY_ITEMS: &str = r#"
|
||||
SELECT i.id AS inventory_id, i.quantity AS inventory_quantity, i.stock_id FROM falukant_data.inventory i JOIN falukant_data.stock s ON i.stock_id = s.id JOIN falukant_data.branch b ON s.branch_id = b.id WHERE b.region_id = $1 AND s.stock_type_id = $2;
|
||||
"#;
|
||||
|
||||
pub const QUERY_GET_REGION_STOCKS_BY_TYPE: &str = r#"
|
||||
SELECT s.id AS stock_id,
|
||||
s.quantity AS stock_capacity,
|
||||
COALESCE(SUM(i.quantity), 0)::int AS inventory_quantity
|
||||
FROM falukant_data.stock s
|
||||
JOIN falukant_data.branch b ON s.branch_id = b.id
|
||||
LEFT JOIN falukant_data.inventory i ON i.stock_id = s.id
|
||||
WHERE b.region_id = $1
|
||||
AND s.stock_type_id = $2
|
||||
GROUP BY s.id, s.quantity;
|
||||
"#;
|
||||
|
||||
pub const QUERY_REDUCE_INVENTORY: &str = r#"
|
||||
UPDATE falukant_data.inventory SET quantity = $1 WHERE id = $2;
|
||||
"#;
|
||||
@@ -2726,6 +2744,19 @@ JOIN falukant_data.stock s ON i.stock_id = s.id
|
||||
JOIN falukant_data.branch b ON s.branch_id = b.id
|
||||
WHERE b.falukant_user_id = $1 AND s.stock_type_id = $2;
|
||||
"#;
|
||||
|
||||
pub const QUERY_GET_USER_STOCKS_BY_TYPE: &str = r#"
|
||||
SELECT s.id AS stock_id,
|
||||
b.region_id AS region_id,
|
||||
s.quantity AS stock_capacity,
|
||||
COALESCE(SUM(i.quantity), 0)::int AS inventory_quantity
|
||||
FROM falukant_data.stock s
|
||||
JOIN falukant_data.branch b ON s.branch_id = b.id
|
||||
LEFT JOIN falukant_data.inventory i ON i.stock_id = s.id
|
||||
WHERE b.falukant_user_id = $1
|
||||
AND s.stock_type_id = $2
|
||||
GROUP BY s.id, b.region_id, s.quantity;
|
||||
"#;
|
||||
// Produce worker queries
|
||||
pub const QUERY_GET_FINISHED_PRODUCTIONS: &str = r#"
|
||||
SELECT DISTINCT ON (p.id)
|
||||
|
||||
Reference in New Issue
Block a user