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

create all docs before calling back #424

Merged
merged 7 commits into from
Mar 3, 2015

Conversation

dduugg
Copy link
Contributor

@dduugg dduugg commented Feb 18, 2015

This resolves an issue where the create function in entries.js wasn't waiting for the updates to complete before calling back. This would frequently cause Travis failures, when tests would expect entries that had yet to be completed.

resolves #423

@coveralls
Copy link

Coverage Status

Coverage remained the same at 70.82% when pulling cd047fa on dduugg:wip/fix-create into 57c8e99 on nightscout:dev.

docs.forEach(function(doc) {
collection.update(doc, doc, {upsert: true}, function (err, created) {
firstErr = firstErr || err;
totalCreated += created;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is especially sketchy, as created is an object, but the initial value of totalCreated is a number, turning totalCreated into a string of the form 0{"ok":1,"nModified":1,"n":1}{"ok":1,"nModified":1,"n":1}...

@bewest
Copy link
Member

bewest commented Feb 18, 2015

Such a fan of this, I created PR, is this good to go or does it need to wait for some reason?

@dduugg
Copy link
Contributor Author

dduugg commented Feb 19, 2015

It's basically good to go from my perspective. One could argue that tests 3 and 2 should be swapped (since test 3 checks for more docs, it's more likely to catch a regression). One could also nitpick that docs.length should not be accessed in every loop iteration (it should be stored as a variable, or the counter should count down to zero).

@coveralls
Copy link

Coverage Status

Coverage remained the same at 70.82% when pulling 0654510 on dduugg:wip/fix-create into 57c8e99 on nightscout:dev.

@dduugg
Copy link
Contributor Author

dduugg commented Feb 20, 2015

Just pushed a commit with precisely those changes.

@dduugg dduugg force-pushed the wip/fix-create branch 2 times, most recently from 1ba55a0 to cfe1e51 Compare February 20, 2015 06:07
@coveralls
Copy link

Coverage Status

Coverage remained the same at 70.82% when pulling cfe1e51 on dduugg:wip/fix-create into 57c8e99 on nightscout:dev.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage remained the same at 70.82% when pulling cfe1e51 on dduugg:wip/fix-create into 57c8e99 on nightscout:dev.

@jasoncalabrese
Copy link
Member

Been out of town, want to a do a quick test and merge this tonight or tomorrow.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 70.87% when pulling b45fc2e on dduugg:wip/fix-create into 57c8e99 on nightscout:dev.

Resolves nightscout#423. Also changes the callback signature, invoking it with the
error and docs, rather than the error, totalCreated, and docs. The third
paramter isn't used, and the second parameter should be an array. (Since
totalCreated was 0 on callback, it was falsy and replaced with an empty
array when used in format_entries.)
flagged by webstorm: "return is unnecessary as the last statement in a
function with no return value"
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.14%) to 70.68% when pulling 13751df on dduugg:wip/fix-create into d616b6c on nightscout:dev.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.14%) to 70.68% when pulling 13751df on dduugg:wip/fix-create into d616b6c on nightscout:dev.

@jasoncalabrese
Copy link
Member

Tested, thanks @dduugg

jasoncalabrese added a commit that referenced this pull request Mar 3, 2015
create all docs before calling back
@jasoncalabrese jasoncalabrese merged commit 5ac9978 into nightscout:dev Mar 3, 2015
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.

None yet

4 participants