def get_notifications(user_address): user_id = MyUser.get_id_by_email(user_address) db = get_db() notifications_rows = db.execute( "SELECT * FROM ques WHERE waiter_id = ? AND place_in_line = 1", (user_id, )).fetchall() notifications: list[Notification] = [] for notification in notifications_rows: callee_id = notification[0] callee = MyUser.get(callee_id) notifications.append( Notification(callee.name, callee.phone, callee.email)) # print("notifications:", notifications) return notifications
def get_my_que(user_address): user_id = MyUser.get_id_by_email(user_address) db = get_db() que_ids = db.execute("SELECT * FROM ques WHERE callee_id = ?", (user_id, )).fetchall() # print(que_ids) que: list[Waiter] = [] for waiter in que_ids: c_id = waiter[1] c_user = MyUser.get(c_id) c_name = c_user.name c_address = c_user.email c_phone = c_user.phone c_waiter = Waiter(email=c_address, name=c_name, phone=c_phone, place=waiter[2]) que.append(c_waiter) # print("que:", que) # sort 'que' according to the 'place' attribute of waiter que.sort(key=lambda x: x.place) # print("que:", que) return que