Files
breakpilot-compliance/ai-compliance-sdk/internal/api/handlers/iace_handler_distances.go
T
Benjamin Admin 6b41eec176 feat(iace): surface OSHA distance anchor in Maßnahmen tab (name-resolved)
Makes the OSHA minimum-distance anchor visible per measure in a project
without a DB schema change or re-seed: persisted mitigations store the
measure NAME verbatim (not the catalog ID), and measure names are unique
across the 578-entry library (pinned by test), so a name→ID resolver
bridges the gap.

Backend: MeasureIDByName + MinimumDistancesForMeasureName/LinksForMeasureName;
/iace/minimum-distances now accepts ?measure_name=; link table enriched with
measure_name for one-request UI matching.
Frontend: useMinimumDistances loads the link table once and keys it by name;
OshaDistanceNote renders the anchor (value/CFR/license/EU-hint/relation) on the
matching measure group in the Maßnahmen tab.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-11 13:39:48 +02:00

38 lines
1.2 KiB
Go

package handlers
import (
"net/http"
"github.com/breakpilot/ai-compliance-sdk/internal/iace"
"github.com/gin-gonic/gin"
)
// ListMinimumDistances handles GET /minimum-distances.
// Read-only OSHA safety-distance reference (29 CFR 1910, US public domain)
// plus the curated measure→distance link table, so an auditor can see WHERE a
// measure's mm figure comes from. Scope to one measure via ?measure_id= or
// ?measure_name= (the latter lets a persisted mitigation — which stores the
// name, not the catalog ID — resolve its anchor without a schema change).
func (h *IACEHandler) ListMinimumDistances(c *gin.Context) {
mid := c.Query("measure_id")
mname := c.Query("measure_name")
if mid == "" && mname != "" {
mid, _ = iace.MeasureIDByName(mname) // "" if unknown → empty scoped result
}
if mid != "" || mname != "" {
c.JSON(http.StatusOK, gin.H{
"measure_id": mid,
"measure_name": mname,
"distances": iace.MinimumDistancesForMeasure(mid),
"links": iace.LinksForMeasure(mid),
"note": iace.MinimumDistanceNote,
})
return
}
c.JSON(http.StatusOK, gin.H{
"distances": iace.GetOSHAMinimumDistances(),
"links": iace.AllMeasureDistanceLinks(),
"note": iace.MinimumDistanceNote,
})
}