feat(phase-16): enhanced Tests view, Red/Blue dashboard metrics, and Template admin panel (T-122, T-123, T-124)
This commit is contained in:
@@ -88,18 +88,37 @@ def _get_test_with_technique(db: Session, test_id: uuid.UUID) -> Test:
|
||||
def list_tests(
|
||||
state: Optional[str] = Query(None, description="Filter by test state"),
|
||||
technique_id: Optional[uuid.UUID] = Query(None, description="Filter by technique"),
|
||||
platform: Optional[str] = Query(None, description="Filter by platform"),
|
||||
created_by: Optional[uuid.UUID] = Query(None, description="Filter by creator"),
|
||||
pending_validation_side: Optional[str] = Query(
|
||||
None, description="Filter in_review tests pending validation on 'red' or 'blue' side"
|
||||
),
|
||||
offset: int = Query(0, ge=0),
|
||||
limit: int = Query(50, ge=1, le=200),
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_current_user),
|
||||
):
|
||||
"""Return a paginated list of tests, optionally filtered by state or technique."""
|
||||
query = db.query(Test)
|
||||
"""Return a paginated list of tests, optionally filtered by state, technique, platform or creator."""
|
||||
query = db.query(Test).options(joinedload(Test.technique))
|
||||
|
||||
if state:
|
||||
query = query.filter(Test.state == state)
|
||||
if technique_id:
|
||||
query = query.filter(Test.technique_id == technique_id)
|
||||
if platform:
|
||||
query = query.filter(Test.platform.ilike(f"%{platform}%"))
|
||||
if created_by:
|
||||
query = query.filter(Test.created_by == created_by)
|
||||
if pending_validation_side == "red":
|
||||
query = query.filter(
|
||||
Test.state == TestState.in_review,
|
||||
Test.red_validation_status.in_(["pending", None]),
|
||||
)
|
||||
elif pending_validation_side == "blue":
|
||||
query = query.filter(
|
||||
Test.state == TestState.in_review,
|
||||
Test.blue_validation_status.in_(["pending", None]),
|
||||
)
|
||||
|
||||
tests = query.order_by(Test.created_at.desc()).offset(offset).limit(limit).all()
|
||||
return tests
|
||||
|
||||
Reference in New Issue
Block a user