def get_full_name(slack_handle): query = Session.query(Employees) \ .filter(Employees.slack_handle == slack_handle) \ .filter(Employees.enabled) \ .limit(1) \ .one() return query.name
def get_random_employee(): from app.Sentences import Sentences query = Session.query(Employees, Sentences) \ .filter(Employees.id == Sentences.employee_id) \ .filter(Employees.enabled) \ .order_by(func.random()) \ .limit(1) \ .one() return query.Employees.slack_handle
def get_all_channels(): return Session.query(Channels) \ .filter(Channels.enabled == True) \ .all()
def get(id): return Session.query(Employees) \ .filter(Employees.id == id) \ .one()
def toggle(slack_id, toggle): Session.query(Employees) \ .filter(Employees.id == slack_id) \ .update({'enabled': toggle}) return Session.commit()