-
Notifications
You must be signed in to change notification settings - Fork 272
fix(plugin-chart-table): refine ordering logic #930
fix(plugin-chart-table): refine ordering logic #930
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/superset/superset-ui/k57lswnpy |
if (timeseriesLimitMetric && orderDesc != null) { | ||
orderby = [[timeseriesLimitMetric, !orderDesc]]; | ||
if (timeseriesLimitMetric.length > 0 && orderDesc != null) { | ||
orderby = [[timeseriesLimitMetric[0], !orderDesc]]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In practice timeseriesLimitMetric
is always truthy, as the control always returns either an empty array (nothing selected) or a string/object (=an orderby is set). See the updated type in types.ts
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, didn't notice the control returns an empty array when nothing is selected. That sounds wrong.
95989ed
to
068d6cf
Compare
Codecov Report
@@ Coverage Diff @@
## master #930 +/- ##
==========================================
+ Coverage 27.32% 27.37% +0.04%
==========================================
Files 411 412 +1
Lines 8281 8292 +11
Branches 1134 1139 +5
==========================================
+ Hits 2263 2270 +7
- Misses 5886 5888 +2
- Partials 132 134 +2
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for the fix!
🐛 Bug Fix
Previously table chart would by default order by the first metric if no sort order was specified. This replicates the logic from the old
viz.py
implementation and also fixes a few minor issues in the current code:queryMode
fromformData
contents; if it's undefined andmetrics
is not empty, assumeQueryMode.aggregate
. This is the case in some old metadata, e.g. the World Bank example dashboard.timeseries_limit_metric
is[]
when the control is unset, andQueryFormMetric
when set. The type is updated and a util is added for normalizing toQueryFormMetric[]
+ relevant tests.AFTER
BEFORE