This commit is contained in:
2025-12-14 10:40:54 +01:00
parent 5d483b0df5
commit 8428bf9c82
55 changed files with 9763 additions and 391 deletions

View File

@@ -11,9 +11,11 @@ from app.db.session import get_db
from app.schemas.device import DeviceListResponse, DeviceDetail, DeviceSummary, DeviceUpdate
from app.schemas.benchmark import BenchmarkSummary
from app.schemas.hardware import HardwareSnapshotResponse
from app.schemas.document import DocumentResponse
from app.models.device import Device
from app.models.benchmark import Benchmark
from app.models.hardware_snapshot import HardwareSnapshot
from app.models.document import Document
router = APIRouter()
@@ -160,6 +162,24 @@ async def get_device(
motherboard_model=last_snapshot.motherboard_model
)
# Get documents for this device
documents = db.query(Document).filter(
Document.device_id == device.id
).all()
documents_list = [
DocumentResponse(
id=doc.id,
device_id=doc.device_id,
doc_type=doc.doc_type,
filename=doc.filename,
mime_type=doc.mime_type,
size_bytes=doc.size_bytes,
uploaded_at=doc.uploaded_at.isoformat()
)
for doc in documents
]
return DeviceDetail(
id=device.id,
hostname=device.hostname,
@@ -172,7 +192,8 @@ async def get_device(
created_at=device.created_at.isoformat(),
updated_at=device.updated_at.isoformat(),
last_benchmark=last_bench_summary,
last_hardware_snapshot=last_snapshot_data
last_hardware_snapshot=last_snapshot_data,
documents=documents_list
)
@@ -246,7 +267,9 @@ async def update_device(
for key, value in update_dict.items():
setattr(device, key, value)
device.updated_at = db.query(Device).filter(Device.id == device_id).first().updated_at
# Update timestamp
from datetime import datetime
device.updated_at = datetime.utcnow()
db.commit()
db.refresh(device)