Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
f4c40030
Commit
f4c40030
authored
9 years ago
by
Allen Gilliland
Browse files
Options
Downloads
Patches
Plain Diff
add migration to fix any dashboard cards with NULL :row or :col values.
parent
ba943228
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/metabase/db/migrations.clj
+21
-0
21 additions, 0 deletions
src/metabase/db/migrations.clj
with
21 additions
and
0 deletions
src/metabase/db/migrations.clj
+
21
−
0
View file @
f4c40030
...
...
@@ -124,6 +124,7 @@
:sizeY
(
when
sizeY
(
*
sizeY
4
))})
(
k/where
{
:id
id
}))))
;; migrate data to new visibility_type column on field
(
defmigration
migrate-field-visibility-type
(
when
(
<
0
(
:cnt
(
first
(
k/select
Field
(
k/aggregate
(
count
:*
)
:cnt
)
(
k/where
(
=
:visibility_type
"unset"
))))))
...
...
@@ -149,3 +150,23 @@
(
k/set-fields
{
:visibility_type
"normal"
})
(
k/where
{
:visibility_type
"unset"
:active
true
}))))
;; deal with dashboard cards which have NULL `:row` or `:col` values
(
defmigration
fix-dashboard-cards-without-positions
(
let
[
bad-dashboards
(
k/select
DashboardCard
(
k/fields
[
:dashboard_id
])
(
k/modifier
"DISTINCT"
)
(
k/where
(
or
(
=
:row
nil
)
(
=
:col
nil
))))]
(
when
(
not-empty
bad-dashboards
)
(
log/info
"Looks like we need to fix unpositioned cards in these dashboards:"
(
mapv
:dashboard_id
bad-dashboards
))
;; we are going to take the easy way out, which is to put bad-cards at the bottom of the dashboard
(
doseq
[{
dash-to-fix
:dashboard_id
}
bad-dashboards
]
(
let
[
max-row
(
or
(
:row
(
first
(
k/select
DashboardCard
(
k/aggregate
(
max
:row
)
:row
)
(
k/where
{
:dashboard_id
dash-to-fix
}))))
0
)
max-size
(
or
(
:size
(
first
(
k/select
DashboardCard
(
k/aggregate
(
max
:sizeY
)
:size
)
(
k/where
{
:dashboard_id
dash-to-fix,
:row
max-row
}))))
0
)
max-y
(
+
max-row
max-size
)
bad-cards
(
k/select
DashboardCard
(
k/fields
:id
:sizeY
)
(
k/where
{
:dashboard_id
dash-to-fix
})
(
k/where
(
or
(
=
:row
nil
)
(
=
:col
nil
))))]
(
loop
[[
bad-card
&
rest
]
bad-cards
row-target
max-y
]
(
k/update
DashboardCard
(
k/set-fields
{
:row
row-target
:col
0
})
(
k/where
{
:id
(
:id
bad-card
)}))
(
when
rest
(
recur
rest
(
+
row-target
(
:sizeY
bad-card
))))))))))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment