feat: standardize device type for Sound Level Meters (SLM)

- Updated all instances of device_type from "sound_level_meter" to "slm" across the codebase.
- Enhanced documentation to reflect the new device type standardization.
- Added migration script to convert legacy device types in the database.
- Updated relevant API endpoints, models, and frontend templates to use the new device type.
- Ensured backward compatibility by deprecating the old device type without data loss.
This commit is contained in:
serversdwn
2026-01-16 18:31:27 +00:00
parent 6c7ce5aad0
commit 1ef0557ccb
22 changed files with 488 additions and 72 deletions

View File

@@ -35,7 +35,7 @@ async def get_slm_stats(request: Request, db: Session = Depends(get_db)):
Returns HTML partial with stat cards.
"""
# Query all SLMs
all_slms = db.query(RosterUnit).filter_by(device_type="sound_level_meter").all()
all_slms = db.query(RosterUnit).filter_by(device_type="slm").all()
# Count deployed vs benched
deployed_count = sum(1 for slm in all_slms if slm.deployed and not slm.retired)
@@ -69,7 +69,7 @@ async def get_slm_units(
Get list of SLM units for the sidebar.
Returns HTML partial with unit cards.
"""
query = db.query(RosterUnit).filter_by(device_type="sound_level_meter")
query = db.query(RosterUnit).filter_by(device_type="slm")
# Filter by project if provided
if project:
@@ -129,7 +129,7 @@ async def get_live_view(request: Request, unit_id: str, db: Session = Depends(ge
Returns HTML partial with live metrics and chart.
"""
# Get unit from database
unit = db.query(RosterUnit).filter_by(id=unit_id, device_type="sound_level_meter").first()
unit = db.query(RosterUnit).filter_by(id=unit_id, device_type="slm").first()
if not unit:
return templates.TemplateResponse("partials/slm_live_view_error.html", {
@@ -242,7 +242,7 @@ async def get_slm_config(request: Request, unit_id: str, db: Session = Depends(g
Get configuration form for a specific SLM unit.
Returns HTML partial with configuration form.
"""
unit = db.query(RosterUnit).filter_by(id=unit_id, device_type="sound_level_meter").first()
unit = db.query(RosterUnit).filter_by(id=unit_id, device_type="slm").first()
if not unit:
return HTMLResponse(
@@ -262,7 +262,7 @@ async def save_slm_config(request: Request, unit_id: str, db: Session = Depends(
Save SLM configuration.
Updates unit parameters in the database.
"""
unit = db.query(RosterUnit).filter_by(id=unit_id, device_type="sound_level_meter").first()
unit = db.query(RosterUnit).filter_by(id=unit_id, device_type="slm").first()
if not unit:
return {"status": "error", "detail": f"Unit {unit_id} not found"}