# meals.append({'id':2, 'kuk':'marek', 'eaters':['davide','sven','david', 'wille'], 'flavor_text':'Grzybowa', 'date':'Friday 23rd 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':'Friday 23rd 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':'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 username as kuk, meal_date, array_agg as eaters, selection_deadline from (select 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;'
r=db_engine.execute(text(query))
meals=[]
meals.append({'id':1,'kuk':'davide','eaters':['marek','sven','wille'],'flavor_text':'Pizza','date':'Tuesday 21st of November','selection_deadline':'23 hours 14 minutes','status':0})
meals.append({'id':2,'kuk':'marek','eaters':['davide','sven','david','wille'],'flavor_text':'Grzybowa','date':'Friday 23rd 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':'Friday 23rd 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':'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})