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

@@ -273,7 +273,7 @@ async def assign_unit_to_location(
raise HTTPException(status_code=404, detail="Unit not found")
# Check device type matches location type
expected_device_type = "sound_level_meter" if location.location_type == "sound" else "seismograph"
expected_device_type = "slm" if location.location_type == "sound" else "seismograph"
if unit.device_type != expected_device_type:
raise HTTPException(
status_code=400,
@@ -375,7 +375,7 @@ async def get_available_units(
Filters by device type matching the location type.
"""
# Determine required device type
required_device_type = "sound_level_meter" if location_type == "sound" else "seismograph"
required_device_type = "slm" if location_type == "sound" else "seismograph"
# Get all units of the required type that are deployed and not retired
all_units = db.query(RosterUnit).filter(
@@ -397,7 +397,7 @@ async def get_available_units(
"id": unit.id,
"device_type": unit.device_type,
"location": unit.address or unit.location,
"model": unit.slm_model if unit.device_type == "sound_level_meter" else unit.unit_type,
"model": unit.slm_model if unit.device_type == "slm" else unit.unit_type,
}
for unit in all_units
if unit.id not in assigned_unit_ids