Пример #1
0
def get_variables(session, limit: Optional[int], offset: Optional[int] = None) -> Response:
    """
    Get all variable values
    """
    total_entries = session.query(func.count(Variable.id)).scalar()
    query = session.query(Variable).order_by(Variable.id)
    if offset:
        query = query.offset(offset)
    if limit:
        query = query.limit(limit)
    variables = query.all()
    return variable_collection_schema.dump({
        "variables": variables,
        "total_entries": total_entries,
    })
Пример #2
0
def get_variables(session,
                  limit: Optional[int],
                  order_by: str = "id",
                  offset: Optional[int] = None) -> Response:
    """Get all variable values"""
    total_entries = session.query(func.count(Variable.id)).scalar()
    to_replace = {"value": "val"}
    allowed_filter_attrs = ['value', 'key', 'id']
    query = session.query(Variable)
    query = apply_sorting(query, order_by, to_replace, allowed_filter_attrs)
    variables = query.offset(offset).limit(limit).all()
    return variable_collection_schema.dump({
        "variables": variables,
        "total_entries": total_entries,
    })