Include meal plan recipes in the calendar (closes #368)

This commit is contained in:
Bernd Bestel
2019-09-24 09:40:56 +02:00
parent 2a9f927a13
commit 53c56cc1cb
3 changed files with 38 additions and 1 deletions

19
migrations/0091.sql Normal file
View File

@@ -0,0 +1,19 @@
DROP VIEW recipes_nestings_resolved;
CREATE VIEW recipes_nestings_resolved
AS
WITH RECURSIVE r1(recipe_id, includes_recipe_id, includes_servings)
AS (
SELECT id, id, 1
FROM recipes
UNION ALL
SELECT rn.recipe_id, r1.includes_recipe_id, rn.servings
FROM recipes_nestings rn, r1 r1
WHERE rn.includes_recipe_id = r1.recipe_id
LIMIT 100 -- This is just a safety limit to prevent infinite loops due to infinite nested recipes
)
SELECT
*,
1 AS id -- Dummy, LessQL needs an id column
FROM r1;