Repository navigation
refactor(storage): move dashboard business logic out of Spanner storage - #1196
Merged
andrzejfudro merged 6 commits intoOct 12, 2026
Merged
Conversation
Extract backend-neutral dashboard and chart business logic out of internal/storage/spanner/dashboard into internal/storage/data so it can be shared across Spanner and PostgreSQL storage repositories: - Field-mask merging (MergeDashboards, MergeCharts), chart-ID sorting/equality (SortChartIDs, ChartIDsEqual), update diffing (PrepareDashboardUpdate), chart-ID deduplication/validation (DeduplicateAndValidateChartIDs, BuildDashboardChartLinks), and layout position mapping (BuildPositionsMap). - Parent-to-filter conversion (BuildChartParentFilter, CombineFilters, BuildListChartsFilter), cursor extractors, and post-query plot/position/chart-ID assembly helpers (IndexDashboardsByID, AssignDashboardChartIDs, ExtractChartIDs, AssignChartPlots, BuildChartPlotsFilter, UnmarshalPlotSpec). Keep the existing DashboardRepository interface and Spanner InsertOrUpdate (upsert) behavior in CreateDashboard unchanged. Bug: b/571899495 TAG=agy CONV=26aeace4-784a-418b-bb9b-c768148ee3bf
There was a problem hiding this comment.
Code Review
This pull request refactors the storage layer by consolidating dashboard and chart helper utilities (such as merging, sorting, layout mapping, and cursor extraction) from Spanner-specific packages into a shared internal/storage/data package. Feedback on these changes focuses on addressing potential runtime panics due to missing nil checks in ExtractChartIDs and AssignChartPlots, improving error propagation in ExtractChartCursor by wrapping grpcerr.ErrInvalidArgument, and validating dashboard parent names in BuildChartParentFilter to prevent malformed filter expressions.
- Validate dashboard parent names with validator.ValidateDashboardName in BuildChartParentFilter. - Wrap grpcerr.ErrInvalidArgument when chart is nil in ExtractChartCursor. - Add defensive nil checks for chart elements in ExtractChartIDs and AssignChartPlots, and add unit test cases in dashboard_test.go. Bug: b/571899495 TAG=agy CONV=26aeace4-784a-418b-bb9b-c768148ee3bf
andrzejfudro
marked this pull request as ready for review
October 12, 2026 12:08
andrzejfudro
enabled auto-merge
October 12, 2026 12:09
pachopepe
reviewed
Oct 12, 2026
…iven tests - Remove unused UnmarshalPlotSpec pass-through wrapper and its duplicate tests from internal/storage/spanner/dashboard/data. - Restore table-driven t.Run subtests for TestChartIDsEqual, TestExtractChartCursor, and TestExtractDashboardCursor in internal/storage/data/dashboard_test.go. - Use cmp.Diff with protocmp.Transform() for AssignChartPlots assertions. Bug: b/571899495 TAG=agy CONV=26aeace4-784a-418b-bb9b-c768148ee3bf
…siness-logic-out-of-spanner # Conflicts: # internal/storage/spanner/dashboard/chartplots.go # internal/storage/spanner/dashboard/data/dashboard.go # internal/storage/spanner/dashboard/listcharts.go # internal/storage/spanner/dashboard/listdashboards.go # internal/storage/spanner/dashboard/updatechart.go # internal/storage/spanner/dashboard/updatedashboard.go
…ashboard path Expose the dashboard messages go_proto_library under the canonical xmanager_cloud/api/protos/dashboard importpath, keeping the legacy xmanager_cloud/dashboard_service/proto/api_go_proto path as an importpath alias (same pattern as api/protos/task_queue). Existing callers are unchanged; the new internal/storage/data files use the canonical path so check_legacy_imports.py no longer regresses. Bug: b/571899495 TAG=agy CONV=26aeace4-784a-418b-bb9b-c768148ee3bf
andrzejfudro
force-pushed
the
refactor/dashboard-business-logic-out-of-spanner
branch
from
October 12, 2026 15:10
5be576c to
2d60185
Compare
Collaborator
Author
|
Import changes are intentional. Needed to add alias due to the parallel effort to remove compat layer. |
pachopepe
approved these changes
Oct 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Moves backend-neutral dashboard and chart merging, diffing, validation, filter construction, and post-query assembly helpers out of
internal/storage/spanner/dashboard/intointernal/storage/data/(b/571899495) so Spanner and upcoming PostgreSQL repositories stay thin and share a single implementation.Key Changes
internal/storage/data: Addeddashboard.goanddashboard_test.gowithMergeDashboards,MergeCharts,PrepareDashboardUpdate,SortChartIDs,ChartIDsEqual,BuildPositionsMap,DeduplicateAndValidateChartIDs,BuildDashboardChartLinks,BuildChartParentFilter,CombineFilters,BuildListChartsFilter, cursor extractors, and post-query dashboard/chart assembly helpers.internal/storage/spanner/dashboard: Updated Spanner dashboard and chart operations (updatedashboard.go,updatechart.go,listcharts.go,listdashboards.go,chartplots.go, anddata/dashboard.go) to delegate tointernal/storage/data, while keepingDashboardRepositoryand SpannerInsertOrUpdatebehavior inCreateDashboardunchanged.internal/storage/data/dashboard_test.goand updated Spanner dashboard unit/integration tests.Verification
bazel test //internal/storage/data:data_test //internal/storage/spanner/dashboard/data:data_test //internal/storage/spanner/dashboard:dashboard_test //cmd/dashboard_service/...(Passed)./.githooks/pre-commit(Passed)TAG=agy
CONV=26aeace4-784a-418b-bb9b-c768148ee3bf