def get_flow(db: Session, flow_id: int, flow_runs=10): flow = db.query(Flow).get(flow_id) flow_runs = (db.query(FlowRun).filter_by(flow=flow).order_by( FlowRun.id.desc()).limit(flow_runs).all()) flow.flow_runs = sorted(flow_runs, key=lambda x: x.id) return flow
def delete_flow(db: Session, flow_id: int): flow = db.query(Flow).get(flow_id) if not flow.is_online: db.delete(flow) db.commit() return get_flows(db)
def get_flows(db: Session, offset: int = 0, limit: int = 10): return db.query(Flow).offset(offset).limit(limit).all()