Skip to content

DM-8214 - handling server errors in charts #244

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

Merged
merged 1 commit into from
Nov 29, 2016
Merged

Conversation

tgoldina
Copy link
Contributor

This pull request is for handling server error in a chart. Prior to it, loading message would not disappear when an error occurred.

The test relies on a bug in 'Clear' options behavior for histogram. When 'Clear' is pressed, all fields histogram options are cleared, including 'Column or expression value'. If options are applied at this point, an empty column is sent to the server, resulting in an error.

});
}
return errors;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-just for your reference, using 'reduce' is nicer than 'forEach' in terms of functional nature.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the note. Indeed, looks like in my code I use forEach a lot, even where simple for loop would be more performant. (See https://jsperf.com/array-reduce-vs-foreach/9) I just find forEach more readable, especially when the values need to be accumulated in an array.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI - we should not worry about performance for stuff like this unless it is clear there is a need. Most of our objects and arrays are so small the speed difference is negligible anyway. Those comparisons will do the same thing like 10,000 times and then compare.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. The only place where it matters is when processing arrays of hundred thousands elements.

Copy link
Contributor

@loitly loitly Nov 30, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Object.entries() is a good alternative.

const errors = Object.entries(chartDataElements)
                                    .filter( ([k,v]) -> v.error)
                                    .map( ([k,v]) -> v.error);

@cwang2016
Copy link
Contributor

review completes. good!

@tgoldina tgoldina merged commit b133a76 into dev Nov 29, 2016
@tgoldina tgoldina deleted the dm-8214_charterr branch November 29, 2016 23:21
@tgoldina
Copy link
Contributor Author

tgoldina commented Nov 30, 2016 via email

@loitly
Copy link
Contributor

loitly commented Nov 30, 2016

We use babel-polyfill with es2015 and stage-2 presets. Object entries and values are supported in babel-polyfill. I think it should be okay. I've used it in several places.
https://babeljs.io/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants