Merge pull request #5727 from overleaf/jpa-deprecation-warnings

[misc] fix deprecation warnings

GitOrigin-RevId: aa103252e5918143bb1dacb19e87e47bb1784e83
This commit is contained in:
Jakob Ackermann 2021-11-08 16:06:12 +01:00 committed by Copybot
parent 97a636b0dd
commit 6122520bf5
4 changed files with 15 additions and 13 deletions

View file

@ -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,

View file

@ -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.')
}

View file

@ -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}`,

View file

@ -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]}`,