From 847337443d22b99eb02631f214f71a9a2194c051 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Tue, 1 Aug 2023 20:47:47 +0200 Subject: [PATCH] Optimized /shoppinglist performance --- changelog/71_UNRELEASED_xxxx-xx-xx.md | 2 +- migrations/0223.sql | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 migrations/0223.sql diff --git a/changelog/71_UNRELEASED_xxxx-xx-xx.md b/changelog/71_UNRELEASED_xxxx-xx-xx.md index 58a34a24..ffb7a7a1 100644 --- a/changelog/71_UNRELEASED_xxxx-xx-xx.md +++ b/changelog/71_UNRELEASED_xxxx-xx-xx.md @@ -8,7 +8,7 @@ ### Stock -- Fixed performance issues related to the stock overview and purchase/consume/inventory/transfer page +- Fixed performance issues affecting the stock overview, shopping list and purchase/consume/inventory/transfer pages - Fixed that the upgrade failed when having improperly defined product specific quantity unit conversions ### Shopping list diff --git a/migrations/0223.sql b/migrations/0223.sql new file mode 100644 index 00000000..2c59cd1e --- /dev/null +++ b/migrations/0223.sql @@ -0,0 +1,27 @@ +DROP VIEW uihelper_shopping_list; +CREATE VIEW uihelper_shopping_list +AS +SELECT + sl.*, + p.name AS product_name, + plp.price AS last_price_unit, + plp.price * sl.amount AS last_price_total, + st.name AS default_shopping_location_name, + qu.name AS qu_name, + qu.name_plural AS qu_name_plural, + pg.id AS product_group_id, + pg.name AS product_group_name, + pbcs.barcodes AS product_barcodes +FROM shopping_list sl +LEFT JOIN products p + ON sl.product_id = p.id +LEFT JOIN products_last_price plp + ON sl.product_id = plp.product_id +LEFT JOIN shopping_locations st + ON p.shopping_location_id = st.id +LEFT JOIN quantity_units qu + ON sl.qu_id = qu.id +LEFT JOIN product_groups pg + ON p.product_group_id = pg.id +LEFT JOIN product_barcodes_comma_separated pbcs + ON sl.product_id = pbcs.product_id;