feat: 自动隐藏被覆盖的打包历史
This commit is contained in:
@@ -103,12 +103,19 @@ def _enrich_tasks(tasks):
|
||||
@router.get("", response_model=List[TaskResponse])
|
||||
async def list_tasks(
|
||||
status: str = None,
|
||||
include_superseded: bool = False,
|
||||
limit: int = 20,
|
||||
offset: int = 0,
|
||||
user: dict = Depends(get_current_user),
|
||||
db: Session = Depends(get_db)
|
||||
):
|
||||
"""获取任务列表"""
|
||||
query = db.query(Task)
|
||||
if include_superseded:
|
||||
if not user.get("is_admin"):
|
||||
raise HTTPException(status_code=403, detail="需要管理员权限")
|
||||
else:
|
||||
query = query.filter(Task.superseded_at.is_(None))
|
||||
if status:
|
||||
query = query.filter(Task.status == status)
|
||||
tasks = query.order_by(Task.created_at.desc()).offset(offset).limit(limit).all()
|
||||
|
||||
Reference in New Issue
Block a user