api.spaceplanner.app

Spaceplanner API
git clone git://jacobedwards.org/api.spaceplanner.app
Log | Files | Refs

commit 5ea3d3b7daef1c48fb567966928e5c0c73087854
parent 64a66c217147e54d40499763721f5f8df5865e6b
Author: Jacob R. Edwards <jacob@jacobedwards.org>
Date:   Tue, 17 Sep 2024 12:51:19 -0700

Fix ObjectID Path method

Paths use the full table name, not the abbreviated type from IDs.

Diffstat:
Minternal/backend/floorplan_data.go | 14+++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/internal/backend/floorplan_data.go b/internal/backend/floorplan_data.go @@ -110,6 +110,17 @@ var ( IDTypeFurnitureMap = "furmap" ) +var tables map[string]string + +func init() { + tables = map[string]string{ + "pnt": "points", + "pntmap": "pointmaps", + "fur": "furniture", + "furmap": "furniture_maps", + } +} + func (e *Env) FurnitureTypes(tx *sql.Tx) (map[string]FurnitureType, error) { types, err := e.CacheTxStmt(tx, "furn_types", `SELECT name from spaceplanner.furniture_types`) @@ -875,7 +886,8 @@ func (o ObjectID) String() string { } func (o ObjectID) Path() string { - return fmt.Sprintf("/%s/%d", o.Type, o.Seq) + /* Type should be verified, so this shouldn't panic */ + return fmt.Sprintf("/%s/%s", tables[o.Type], o) } func (id ObjectID) MarshalJSON() ([]byte, error) {