From 6122520bf58e77c8b418e559c1549808122365b4 Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Mon, 8 Nov 2021 16:06:12 +0100 Subject: [PATCH] Merge pull request #5727 from overleaf/jpa-deprecation-warnings [misc] fix deprecation warnings GitOrigin-RevId: aa103252e5918143bb1dacb19e87e47bb1784e83 --- .../src/Features/Subscription/RecurlyWrapper.js | 6 +++--- .../scripts/regenerate_duplicate_referral_ids.js | 15 ++++++++++----- services/web/test/acceptance/src/ApiClsiTests.js | 2 +- .../src/RegenerateDuplicateReferralIdsTests.js | 5 +---- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/services/web/app/src/Features/Subscription/RecurlyWrapper.js b/services/web/app/src/Features/Subscription/RecurlyWrapper.js index 92755e7d94..f8110ce0f4 100644 --- a/services/web/app/src/Features/Subscription/RecurlyWrapper.js +++ b/services/web/app/src/Features/Subscription/RecurlyWrapper.js @@ -439,9 +439,9 @@ const RecurlyWrapper = { apiRequest(options, callback) { options.url = RecurlyWrapper.apiUrl + '/' + options.url options.headers = { - Authorization: `Basic ${new Buffer(Settings.apis.recurly.apiKey).toString( - 'base64' - )}`, + Authorization: `Basic ${Buffer.from( + Settings.apis.recurly.apiKey + ).toString('base64')}`, Accept: 'application/xml', 'Content-Type': 'application/xml; charset=utf-8', 'X-Api-Version': Settings.apis.recurly.apiVersion, diff --git a/services/web/scripts/regenerate_duplicate_referral_ids.js b/services/web/scripts/regenerate_duplicate_referral_ids.js index 46295fd704..b64d614a9e 100644 --- a/services/web/scripts/regenerate_duplicate_referral_ids.js +++ b/services/web/scripts/regenerate_duplicate_referral_ids.js @@ -70,11 +70,16 @@ async function processBatch(_, users) { await rewriteDuplicates(uniqueReferalIdsInBatch) return } - const nMatching = await db.users.count( - { referal_id: { $in: uniqueReferalIdsInBatch } }, - { readPreference: ReadPreference.SECONDARY } - ) - if (nMatching !== uniqueReferalIdsInBatch.length) { + const matches = await db.users + .find( + { referal_id: { $in: uniqueReferalIdsInBatch } }, + { + readPreference: ReadPreference.SECONDARY, + projection: { _id: true }, + } + ) + .toArray() + if (matches.length !== uniqueReferalIdsInBatch.length) { if (VERBOSE_LOGGING) { console.log('Got duplicates from running count.') } diff --git a/services/web/test/acceptance/src/ApiClsiTests.js b/services/web/test/acceptance/src/ApiClsiTests.js index 0fb47acca9..599a8cea4b 100644 --- a/services/web/test/acceptance/src/ApiClsiTests.js +++ b/services/web/test/acceptance/src/ApiClsiTests.js @@ -16,7 +16,7 @@ const { expect } = require('chai') const request = require('./helpers/request') const Settings = require('@overleaf/settings') -const auth = new Buffer('sharelatex:password').toString('base64') +const auth = Buffer.from('sharelatex:password').toString('base64') const authed_request = request.defaults({ headers: { Authorization: `Basic ${auth}`, diff --git a/services/web/test/acceptance/src/RegenerateDuplicateReferralIdsTests.js b/services/web/test/acceptance/src/RegenerateDuplicateReferralIdsTests.js index c612c9c2cb..5a0d564af5 100644 --- a/services/web/test/acceptance/src/RegenerateDuplicateReferralIdsTests.js +++ b/services/web/test/acceptance/src/RegenerateDuplicateReferralIdsTests.js @@ -108,10 +108,7 @@ describe('RegenerateDuplicateReferralIds', function () { it('should do the correct operations', function () { let { stderr: stdErr, stdout: stdOut } = result - stdErr = stdErr - .split('\n') - .filter(line => !line.includes('DeprecationWarning')) - .filter(filterOutput) + stdErr = stdErr.split('\n').filter(filterOutput) stdOut = stdOut.split('\n').filter(filterOutput) expect(stdErr).to.deep.equal([ `Completed batch ending ${firstBatch[BATCH_SIZE - 1]}`,