Esempio n. 1
0
def generate_leaderboard():
    all_users: List[UserTable] = UserTable.query.order_by(
        UserTable.is_disqualified.asc(),
        UserTable.is_admin.asc(),
        UserTable.current_level.desc(),
        UserTable.last_question_answered_at.asc(),
    ).all()
    return map_to_list(clean_node, all_users)
Esempio n. 2
0
def handler(data: ParsedRequest):
    action = data.action
    ip = data.client_ip
    current = get_current_user()
    if action == "1":
        return {"success": "Ok"}
        js = data.json
        type_ = js.pop("type")
        user = current or None
        log = Logs(type_, user, ip, js_time(), js)
        add_to_db(log)
        return {"success": "Ok"}
    if action == "get":
        return {}
        if current is None:
            return {"error": "Not authenticated"}
        user = get_user_by_id(current)
        if user is None or not user.is_admin:
            return {"error": "Not authenticated"}
        ret = query_all(Logs)
        return map_to_list(lambda x: x.as_json, ret)
def get_all_users():
    return map_to_list(lambda x: x.as_json, query_all(UserTable))
def get_all_questions():
    return map_to_list(
        get_question_data,
        Questions.query.order_by(Questions.question_level).all())
Esempio n. 5
0
def user_list():
    all_users: List[UserTable] = UserTable.query.order_by(
        UserTable.is_admin.asc(), UserTable.created_at.asc()).all()
    return {"users": map_to_list(clean_node, all_users)}