From 6692d08f7e3c9c533f6a08df5cc1d97467171559 Mon Sep 17 00:00:00 2001 From: Christian Simon Date: Tue, 2 Dec 2025 17:15:26 +0000 Subject: [PATCH] Fix some linting problems --- pkg/api/exploremap.go | 21 ++++++++++---------- pkg/api/http_server.go | 2 +- pkg/server/wire.go | 2 +- pkg/services/exploremap/realtime/channels.go | 4 ++-- pkg/services/exploremap/realtime/hub.go | 14 +++++++++---- 5 files changed, 25 insertions(+), 18 deletions(-) diff --git a/pkg/api/exploremap.go b/pkg/api/exploremap.go index 5ae26cd46a3..fdf9f58f432 100644 --- a/pkg/api/exploremap.go +++ b/pkg/api/exploremap.go @@ -1,6 +1,7 @@ package api import ( + "errors" "net/http" "github.com/grafana/grafana/pkg/api/response" @@ -96,7 +97,7 @@ type CreateExploreMapResponse struct { // 500: internalServerError func (hs *HTTPServer) listExploreMaps(c *contextmodel.ReqContext) response.Response { query := &exploremap.GetExploreMapsQuery{ - OrgID: c.SignedInUser.GetOrgID(), + OrgID: c.GetOrgID(), Limit: c.QueryInt("limit"), } @@ -126,12 +127,12 @@ func (hs *HTTPServer) getExploreMap(c *contextmodel.ReqContext) response.Respons uid := web.Params(c.Req)[":uid"] query := &exploremap.GetExploreMapByUIDQuery{ UID: uid, - OrgID: c.SignedInUser.GetOrgID(), + OrgID: c.GetOrgID(), } m, err := hs.exploreMapService.Get(c.Req.Context(), query) if err != nil { - if err == exploremap.ErrExploreMapNotFound { + if errors.Is(err, exploremap.ErrExploreMapNotFound) { return response.Error(http.StatusNotFound, "Explore map not found", err) } return response.Error(http.StatusInternalServerError, "Failed to get explore map", err) @@ -155,8 +156,8 @@ func (hs *HTTPServer) createExploreMap(c *contextmodel.ReqContext) response.Resp return response.Error(http.StatusBadRequest, "bad request data", err) } - cmd.OrgID = c.SignedInUser.GetOrgID() - cmd.CreatedBy = c.SignedInUser.UserID + cmd.OrgID = c.GetOrgID() + cmd.CreatedBy = c.UserID m, err := hs.exploreMapService.Create(c.Req.Context(), &cmd) if err != nil { @@ -184,12 +185,12 @@ func (hs *HTTPServer) updateExploreMap(c *contextmodel.ReqContext) response.Resp } cmd.UID = uid - cmd.OrgID = c.SignedInUser.GetOrgID() - cmd.UpdatedBy = c.SignedInUser.UserID + cmd.OrgID = c.GetOrgID() + cmd.UpdatedBy = c.UserID m, err := hs.exploreMapService.Update(c.Req.Context(), &cmd) if err != nil { - if err == exploremap.ErrExploreMapNotFound { + if errors.Is(err, exploremap.ErrExploreMapNotFound) { return response.Error(http.StatusNotFound, "Explore map not found", err) } return response.Error(http.StatusInternalServerError, "Failed to update explore map", err) @@ -212,12 +213,12 @@ func (hs *HTTPServer) deleteExploreMap(c *contextmodel.ReqContext) response.Resp uid := web.Params(c.Req)[":uid"] cmd := &exploremap.DeleteExploreMapCommand{ UID: uid, - OrgID: c.SignedInUser.GetOrgID(), + OrgID: c.GetOrgID(), } err := hs.exploreMapService.Delete(c.Req.Context(), cmd) if err != nil { - if err == exploremap.ErrExploreMapNotFound { + if errors.Is(err, exploremap.ErrExploreMapNotFound) { return response.Error(http.StatusNotFound, "Explore map not found", err) } return response.Error(http.StatusInternalServerError, "Failed to delete explore map", err) diff --git a/pkg/api/http_server.go b/pkg/api/http_server.go index 42a8a9ce7e7..157321d5a5b 100644 --- a/pkg/api/http_server.go +++ b/pkg/api/http_server.go @@ -64,6 +64,7 @@ import ( "github.com/grafana/grafana/pkg/services/datasources" "github.com/grafana/grafana/pkg/services/datasources/guardian" "github.com/grafana/grafana/pkg/services/encryption" + "github.com/grafana/grafana/pkg/services/exploremap" "github.com/grafana/grafana/pkg/services/featuremgmt" "github.com/grafana/grafana/pkg/services/folder" "github.com/grafana/grafana/pkg/services/hooks" @@ -80,7 +81,6 @@ import ( "github.com/grafana/grafana/pkg/services/oauthtoken" "github.com/grafana/grafana/pkg/services/org" "github.com/grafana/grafana/pkg/services/playlist" - "github.com/grafana/grafana/pkg/services/exploremap" "github.com/grafana/grafana/pkg/services/plugindashboards" "github.com/grafana/grafana/pkg/services/pluginsintegration/managedplugins" "github.com/grafana/grafana/pkg/services/pluginsintegration/pluginassets" diff --git a/pkg/server/wire.go b/pkg/server/wire.go index 0c9216d78ec..c44153d1c0b 100644 --- a/pkg/server/wire.go +++ b/pkg/server/wire.go @@ -91,6 +91,7 @@ import ( "github.com/grafana/grafana/pkg/services/dsquerierclient" "github.com/grafana/grafana/pkg/services/encryption" encryptionservice "github.com/grafana/grafana/pkg/services/encryption/service" + "github.com/grafana/grafana/pkg/services/exploremap/exploremapimpl" "github.com/grafana/grafana/pkg/services/extsvcauth" extsvcreg "github.com/grafana/grafana/pkg/services/extsvcauth/registry" "github.com/grafana/grafana/pkg/services/featuremgmt" @@ -120,7 +121,6 @@ import ( "github.com/grafana/grafana/pkg/services/oauthtoken/oauthtokentest" "github.com/grafana/grafana/pkg/services/org/orgimpl" "github.com/grafana/grafana/pkg/services/playlist/playlistimpl" - "github.com/grafana/grafana/pkg/services/exploremap/exploremapimpl" "github.com/grafana/grafana/pkg/services/plugindashboards" plugindashboardsservice "github.com/grafana/grafana/pkg/services/plugindashboards/service" "github.com/grafana/grafana/pkg/services/pluginsintegration" diff --git a/pkg/services/exploremap/realtime/channels.go b/pkg/services/exploremap/realtime/channels.go index d843f911425..bbb8ed23a5b 100644 --- a/pkg/services/exploremap/realtime/channels.go +++ b/pkg/services/exploremap/realtime/channels.go @@ -66,8 +66,8 @@ func (h *ExploreMapChannelHandler) OnSubscribe(ctx context.Context, user identit type messageType string const ( - MessageTypeCursorUpdate messageType = "cursor_update" - MessageTypeCursorLeave messageType = "cursor_leave" + MessageTypeCursorUpdate messageType = "cursor_update" + MessageTypeCursorLeave messageType = "cursor_leave" MessageTypeViewportUpdate messageType = "viewport_update" ) diff --git a/pkg/services/exploremap/realtime/hub.go b/pkg/services/exploremap/realtime/hub.go index 3bce3315636..ea59edae29e 100644 --- a/pkg/services/exploremap/realtime/hub.go +++ b/pkg/services/exploremap/realtime/hub.go @@ -3,6 +3,7 @@ package realtime import ( "context" "encoding/json" + "errors" "fmt" "sync" "time" @@ -26,7 +27,6 @@ type OperationHub struct { liveService *live.GrafanaLive store Store states *StateCache - mu sync.RWMutex } // StateCache holds in-memory CRDT states for active maps @@ -124,8 +124,14 @@ func (h *OperationHub) applyOperation(state *MapState, op crdt.Operation) error } } - // Other operation types don't need special handling in the hub - // They're applied at the client level + case crdt.OpUpdatePanelPosition, + crdt.OpUpdatePanelSize, + crdt.OpUpdatePanelZIndex, + crdt.OpUpdatePanelExplore, + crdt.OpAddComment, + crdt.OpRemoveComment: + // These operation types don't need special handling in the hub + // They're applied at the client level } return nil @@ -199,7 +205,7 @@ func (h *OperationHub) snapshotAll(ctx context.Context) { for _, uid := range mapUIDs { if err := h.SnapshotState(ctx, uid); err != nil { // Ignore "not found" errors - map may have been deleted or not yet created - if err != exploremap.ErrExploreMapNotFound { + if !errors.Is(err, exploremap.ErrExploreMapNotFound) { logger.Warn("Failed to snapshot state", "error", err, "mapUid", uid) } }