mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 20:26:42 +00:00
Optimized week recipe handling in mealplan (fixes #2168)
This commit is contained in:
27
migrations/0217.sql
Normal file
27
migrations/0217.sql
Normal file
@@ -0,0 +1,27 @@
|
||||
DROP VIEW meal_plan_internal_recipe_relation;
|
||||
CREATE VIEW meal_plan_internal_recipe_relation
|
||||
AS
|
||||
|
||||
-- Relation between a meal plan (day) and the corresponding internal recipe(s)
|
||||
|
||||
SELECT mp.day, r.id AS recipe_id
|
||||
FROM meal_plan mp
|
||||
JOIN recipes r
|
||||
ON r.name = CAST(mp.day AS TEXT)
|
||||
AND r.type = 'mealplan-day'
|
||||
|
||||
UNION
|
||||
|
||||
SELECT mp.day, r.id AS recipe_id
|
||||
FROM meal_plan mp
|
||||
JOIN recipes r
|
||||
ON r.name = LTRIM(STRFTIME('%Y-%W', mp.day), '0')
|
||||
AND r.type = 'mealplan-week'
|
||||
|
||||
UNION
|
||||
|
||||
SELECT mp.day, r.id AS recipe_id
|
||||
FROM meal_plan mp
|
||||
JOIN recipes r
|
||||
ON r.name = CAST(mp.day AS TEXT) || '#' || CAST(mp.id AS TEXT)
|
||||
AND r.type = 'mealplan-shadow';
|
Reference in New Issue
Block a user