-
Notifications
You must be signed in to change notification settings - Fork 14k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Table view] Handle empty arrays in fd.timeseries_limit_metric #5715
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5715 +/- ##
==========================================
+ Coverage 63.43% 63.78% +0.35%
==========================================
Files 361 362 +1
Lines 22977 22983 +6
Branches 2558 2557 -1
==========================================
+ Hits 14575 14660 +85
+ Misses 8387 8308 -79
Partials 15 15
Continue to review full report at Codecov.
|
@@ -185,9 +185,12 @@ function tableVis(slice, payload) { | |||
container.find('.dataTables_wrapper'), height); | |||
// Sorting table by main column | |||
let sortBy; | |||
if (fd.timeseries_limit_metric) { | |||
const limitMetric = Array.isArray(fd.timeseries_limit_metric) |
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.
No need to check on .length
?
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.
Technically no, if the array has no elements then limitMetric
is undefined
, which is false and does the expected in line 191.
// Sort by as specified | ||
sortBy = fd.timeseries_limit_metric.label || fd.timeseries_limit_metric; | ||
sortBy = limitMetric.label || limitMetric; |
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.
Unrelated to this PR: It's driving me crazy the number of places in the code where we deal with the historical metrics! We'll need to clean that up some day. Maybe that can be an early place where we enforce a typescript schema, and do it way upstream.
LGTM |
…e#5715) * Handle empty arrays * Remove test code * Adding unit test * Fix unit tests * Remove logging
…e#5715) * Handle empty arrays * Remove test code * Adding unit test * Fix unit tests * Remove logging
In some of our charts
fd.timeseries_limit_metric
is being initialized to an empty array instead ofnull
. This results insortBy
being set to an empty array, and then the last metric column is hidden.