Skip to content
This repository has been archived by the owner on Jun 6, 2019. It is now read-only.

Sanity check on reconcileStamp #53

Merged
merged 9 commits into from
Apr 11, 2018
Merged

Conversation

mrose17
Copy link
Contributor

@mrose17 mrose17 commented Apr 10, 2018

No description provided.

@mrose17 mrose17 requested a review from NejcZdovc April 10, 2018 00:43
index.js Outdated
if (self.state.properties.days) self.state.reconcileStamp = self.state.properties.days * msecs.day
if ((self.state.reconcileStamp === null) || (isNaN(self.state.reconcileStamp))) self.state.reconcileStamp = 14 * msecs.day
self._log('sync', { reconcileStamp: self.state.reconcileStamp })
return self.setTimeUntilReconcile(null, callback)
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't this be return self.setTimeUntilReconcile(self.state.reconcileStamp, callback)

Copy link
Contributor

Choose a reason for hiding this comment

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

because if we send null back, reconcile will be pushed back for 30 days

Copy link
Contributor Author

Choose a reason for hiding this comment

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

s/ @diracdeltas / @NejcZdovc / in description above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@NejcZdovc - you raise a good point. please let me know if the latest revision addresses it. thanks!

@NejcZdovc NejcZdovc self-requested a review April 10, 2018 05:41
index.js Outdated
@@ -115,6 +115,13 @@ Client.prototype.sync = function (callback) {
if (typeof callback !== 'function') throw new Error('sync missing callback parameter')

if (!self.state.properties) self.state.properties = {}
if ((self.state.reconcileStamp === null) || (isNaN(self.state.reconcileStamp))) {
if (self.state.properties.reconcileDate) self.state.reconcileStamp = new Date(self.state.properties.reconcileDate).getTime()
if (self.state.properties.days) self.state.reconcileStamp = self.state.properties.days * msecs.day
Copy link
Contributor

Choose a reason for hiding this comment

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

do you actually want self.state.properties.days to override self.state.properties.reconcileDate, or should this be else if instead of if?

@diracdeltas
Copy link
Contributor

please add some unit tests for what this function is expected to do

mrose17 added 3 commits April 10, 2018 04:34
After thinking about the comment from @NejcZdovc, I have concluded that
simpler is better in this recovery case.
@NejcZdovc NejcZdovc force-pushed the sanity-check-on-reconcileStamp branch from 5f75f07 to 4463a59 Compare April 11, 2018 05:50
@NejcZdovc
Copy link
Contributor

@diracdeltas tests added for code change. Also added tests for setTimeUntilReconcile just to be sure

@NejcZdovc NejcZdovc requested a review from diracdeltas April 11, 2018 06:01
@mrose17 mrose17 merged commit dd36177 into master Apr 11, 2018
@mrose17 mrose17 deleted the sanity-check-on-reconcileStamp branch April 11, 2018 16:37
@diracdeltas
Copy link
Contributor

diracdeltas commented Apr 13, 2018

apparently this broke the integration tests (my bad, i didn't know they existed so i only checked unit tests). #49 seems important for preventing this in the future.

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

Successfully merging this pull request may close these issues.

3 participants