fix: resolve architecture validation errors and warnings
- Move database operations from API to service layer:
- Add create_pending_scan() method to code_quality_service
- Add get_running_scans() method to code_quality_service
- Update API to use service methods instead of direct db queries
- Replace inline SVG spinner with $icon('spinner', ...) helper
- Add comment documenting custom dropdown exception
Validation now passes with 0 errors.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,7 +4,7 @@ RESTful API for code quality validation and violation management
|
||||
Supports multiple validator types: architecture, security, performance
|
||||
"""
|
||||
|
||||
from datetime import UTC, datetime
|
||||
from datetime import datetime
|
||||
from enum import Enum
|
||||
|
||||
from fastapi import APIRouter, BackgroundTasks, Depends, Query
|
||||
@@ -214,15 +214,10 @@ async def trigger_scan(
|
||||
triggered_by = f"manual:{current_user.username}"
|
||||
|
||||
for vtype in request.validator_types:
|
||||
# Create scan record with pending status
|
||||
scan = ArchitectureScan(
|
||||
timestamp=datetime.now(UTC),
|
||||
validator_type=vtype.value,
|
||||
status="pending",
|
||||
triggered_by=triggered_by,
|
||||
# Create scan record with pending status via service
|
||||
scan = code_quality_service.create_pending_scan(
|
||||
db, validator_type=vtype.value, triggered_by=triggered_by
|
||||
)
|
||||
db.add(scan)
|
||||
db.flush() # Get scan.id
|
||||
|
||||
# Queue background task
|
||||
background_tasks.add_task(execute_code_quality_scan, scan.id)
|
||||
@@ -257,7 +252,7 @@ async def get_scan_status(
|
||||
|
||||
Use this endpoint to poll for scan completion.
|
||||
"""
|
||||
scan = db.query(ArchitectureScan).filter(ArchitectureScan.id == scan_id).first()
|
||||
scan = code_quality_service.get_scan_by_id(db, scan_id)
|
||||
if not scan:
|
||||
raise ScanNotFoundException(scan_id)
|
||||
|
||||
@@ -274,12 +269,7 @@ async def get_running_scans(
|
||||
|
||||
Returns scans with status 'pending' or 'running'.
|
||||
"""
|
||||
scans = (
|
||||
db.query(ArchitectureScan)
|
||||
.filter(ArchitectureScan.status.in_(["pending", "running"]))
|
||||
.order_by(ArchitectureScan.timestamp.desc())
|
||||
.all()
|
||||
)
|
||||
scans = code_quality_service.get_running_scans(db)
|
||||
return [_scan_to_response(scan) for scan in scans]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user