def METHOD_NAME(session, filter_data=None):
    """Generate query based on filter data
    :param filter_data: Filter data
    :type filter_data: `dict`
    :return:
    :rtype:
    """
    if filter_data is None:
        filter_data = {}
    query = session.query(Session)
    # it doesn't make sense to search in a boolean column :P
    if filter_data.get("active", None):
        if isinstance(filter_data.get("active"), list):
            filter_data["active"] = filter_data["active"][0]
        query = query.filter_by(active=str2bool(filter_data["active"]))
    return query.order_by(Session.id)