From 8d6e72bd8f63ec77f94fa3dfeca5fb9bc891fa5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Alby?= Date: Tue, 10 Dec 2019 13:40:14 +0530 Subject: [PATCH] Merge pull request #2446 from overleaf/ta-refresh-features-script-fix Script To Refresh All Users' Features Fix GitOrigin-RevId: 545c68e6fd868bd50baf27e8e9e987bbeaf72732 --- services/web/scripts/refresh_features.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/services/web/scripts/refresh_features.js b/services/web/scripts/refresh_features.js index d4655edc48..dcf7f82e4e 100644 --- a/services/web/scripts/refresh_features.js +++ b/services/web/scripts/refresh_features.js @@ -7,7 +7,7 @@ const UserFeaturesUpdater = require('../app/src/Features/Subscription/UserFeatur const getMismatchReasons = (currentFeatures, expectedFeatures) => { if (_.isEqual(currentFeatures, expectedFeatures)) { - return null + return {} } let mismatchReasons = {} @@ -23,7 +23,11 @@ const getMismatchReasons = (currentFeatures, expectedFeatures) => { } const normalizeMismatchReasons = mismatchReasons => { - if (mismatchReasons.collaborators > 1 && mismatchReasons.collaborators < 10) { + if ( + mismatchReasons.collaborators > 1 && + mismatchReasons.collaborators < 10 && + mismatchReasons.collaborators !== 6 + ) { mismatchReasons.collaborators = 10 } @@ -63,7 +67,7 @@ const checkAndUpdateUser = (user, callback) => } let mismatchReasons = getMismatchReasons(user.features, freshFeatures) - if (!mismatchReasons) { + if (Object.keys(mismatchReasons).length === 0) { // features are matching; nothing else to do return callback() } @@ -97,6 +101,7 @@ const loopForUsers = (lastUserId, callback) => { } db.users .find(query, { features: 1, lastLoggedIn: 1 }) + .sort('_id') .limit(FETCH_LIMIT, (error, users) => { if (error) { return callback(error)