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

Bugfix challenge tags to normal tags after a challenge has ended/deleted #12341

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Change from update to bulkwrite
  • Loading branch information
tsukimi2 committed Aug 22, 2020
commit 5c12c0a732b7cbf9beca3046dbfb0da26ec88468
17 changes: 12 additions & 5 deletions migrations/users/tag-challenge-field-string2bool.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ db.users.updateOne({
})
*/
async function updateUser (user) {
console.log('updateUser');
count += 1;

const query = {
Expand All @@ -66,11 +67,17 @@ async function updateUser (user) {
},
};

const opts = {
arrayFilters: [{ 'element.challenge': 'true' }],
};

if (count % progressCount === 0) console.warn(`${count} ${user._id}`);

return User.updateOne(query, update, opts).exec();
return User.bulkWrite(
paglias marked this conversation as resolved.
Show resolved Hide resolved
[
{
updateOne: {
filter: query,
update,
arrayFilters: [{ 'element.challenge': 'true' }],
},
},
],
);
}