# meals.append({'id':2, 'kuk':'marek', 'eaters':['davide','sven','david', 'wille'], 'flavor_text':'Grzybowa', 'date':'Sunday 25rd of November', 'selection_deadline':'3 Days 23 hours', 'status':0})
# meals.append({'id':2, 'kuk':'marek', 'eaters':['davide','sven','david', 'wille'], 'flavor_text':'Grzybowa', 'date':'Sunday 25rd of November', 'selection_deadline':'3 Days 23 hours', 'status':0})
# meals.append({'id':2, 'kuk':'marek', 'eaters':['davide','sven','david', 'wille'], 'flavor_text':'Grzybowa', 'date':'Monday 26rd of November', 'selection_deadline':'3 Days 23 hours', 'status':0})
query='select foo.id, username as kuk, meal_date, array_agg as eaters, selection_deadline, is_lazy from (select is_lazy, meals.id, kuk, meal_date, selection_deadline, array_agg(username) from meals join users on users.id = any(meals.eaters) where meals.status=0 group by meals.id order by meal_date) as foo join users on kuk=users.id;'
query='SELECT foo.id, username AS kuk, meal_date, array_agg AS eaters, selection_deadline, is_lazy FROM (SELECT is_lazy, meals.id, kuk, meal_date, selection_deadline, array_agg(username) FROM meals JOIN users ON users.id = any(meals.eaters) WHERE meals.status=0 GROUP BY meals.id ORDER BY meal_date) AS foo JOIN users ON kuk=users.id;'
query='select foo.id, username as kuk, meal_date, array_agg as eaters, selection_deadline from (select meals.id, kuk, meal_date, selection_deadline, array_agg(username) from meals join users on users.id = any(meals.eaters) where meals.id=:meal_id group by meals.id order by meal_date) as foo join users on kuk=users.id;'
query='SELECT foo.id, username AS kuk, meal_date, array_agg AS eaters, selection_deadline FROM (SELECT meals.id, kuk, meal_date, selection_deadline, array_agg(username) FROM meals JOIN users ON users.id = any(meals.eaters) WHERE meals.id=:meal_id GROUP BY meals.id ORDER BY meal_date) AS foo JOIN users ON kuk=users.id;'
r=db_engine.execute(text(query),meal_id=meal_id)
meals=[]
forrowinr:
@ -143,7 +143,7 @@ def getMeal(meal_id):
@login_required
defaddme():
meal_id=request.args.get('meal')
query='select :user_id = any (eaters) as is_eater from meals where id =:meal_id;'
query='SELECT :user_id = any (eaters) AS is_eater FROM meals WHERE id =:meal_id;'