From 5d8649ffe5f24684520e79d7d9d0c80848b5b47e Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Thu, 22 Jan 2026 17:53:10 +0000 Subject: [PATCH] Send down h3 cell with API response I broke this at some point while doing a refactor and didn't notice until now. --- api/types.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/api/types.go b/api/types.go index 1f23fdc9..cac810a6 100644 --- a/api/types.go +++ b/api/types.go @@ -5,9 +5,11 @@ import ( "time" "github.com/Gleipnir-Technology/nidus-sync/db/models" + "github.com/Gleipnir-Technology/nidus-sync/h3utils" "github.com/Gleipnir-Technology/nidus-sync/platform" "github.com/aarondl/opt/null" "github.com/go-chi/render" + "github.com/rs/zerolog/log" ) type H3Cell uint64 @@ -171,13 +173,18 @@ func (rtd ResponseMosquitoSource) Render(w http.ResponseWriter, r *http.Request) func NewResponseMosquitoSource(ms platform.MosquitoSource) ResponseMosquitoSource { pl := ms.PointLocation + h3cell, err := h3utils.ToCell(pl.H3cell.GetOr("0")) + if err != nil { + log.Warn().Err(err).Msg("Failed to convert h3 cell") + h3cell = 0 + } return ResponseMosquitoSource{ - Active: toBool16(pl.Active), - Access: pl.Accessdesc.GetOr(""), - Comments: pl.Comments.GetOr(""), - Created: formatTime(pl.Creationdate), - Description: pl.Description.GetOr(""), - //H3Cell: pl.H3Cell, + Active: toBool16(pl.Active), + Access: pl.Accessdesc.GetOr(""), + Comments: pl.Comments.GetOr(""), + Created: formatTime(pl.Creationdate), + Description: pl.Description.GetOr(""), + H3Cell: int64(h3cell), ID: pl.Globalid.String(), LastInspectionDate: formatTime(pl.Lastinspectdate), Habitat: pl.Habitat.GetOr(""),