Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Copied from #22. Moved into branch on this repo so circleci would run.
Description of change
API returns negative timestamps on occasion. Technically, a negative timestamp value is not invalid as it is simply a date prior to 01-01-1970 but it is likely that this is just bad data being sent by the Intercom API as one of the examples was sending back a negative timestamp for the
signed_up_at
field. Furthermore, the API is also inconsistent about sending timestamps in unix seconds or unix milliseconds so theget_integer_places
function was designed to try and determine the units of the timestamp. This is where passing in a negative timestamp would cause the program to fail because the function tries to take the log of a value but you cannot take the log of a negative number. This fix only prevents the program from failing when given a negative timestamp but does not try to determine if the timestamp is in seconds or milliseconds as 1) it would not be guaranteed anyway and 2) it is likely bad data anyway. Furthermore, unit tests are included to ensure that theget_integer_places
function will properly handle negative timestamps and that these negative timestamps will be properly converted to string dates downstream.Manual QA steps
python -m nose
to run unit tests.Risks
Rollback steps