Skip to content
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

Filter out double values with NaN #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cpdk
Copy link

@cpdk cpdk commented May 31, 2021

I have seen issues where in certain cases my GPS coordinates where NaN - which causes Timestream to reject the entire batch of values.

Filtering is done after initial filtering in line 60 to allow for type to be determined and only filter out DOUBLE values that are NaN.

Copy link
Owner

@c33howard c33howard left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. Nice catch! I must have very clean data. :-)

@@ -97,6 +97,10 @@ module.exports = function(app) {
Time: `${point.timestamp}`
};
});

// filter out NaN double values as they cause Timestream to reject the batch
records = records.filter((r) => (r.MeasureValueType != 'DOUBLE' || !Number.isNaN(Number(r.MeasureValue))));
Copy link
Owner

Choose a reason for hiding this comment

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

I'm curious why you decided to do this after the conversion to timestream's request format, rather than before. I can see pros and cons both ways, so curious as to your thought process.

My care factor is much lower for the rest of the comments on this single line change. :-)

I'm already using lodash, would _.reject() read better, since you've got a couple negations? https://lodash.com/docs/4.17.15#reject

For good or ill, I've also gone with the more verbose function() style, rather than the => style. Mind switching to blend in?

Also, my javascript-fu is weak. I'm a bit surprised it's legal to redefine records as it's const. Purely for my education, how should I be thinking about this?

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.

2 participants