Преглед изворни кода

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

[misc] fix deprecation warnings

GitOrigin-RevId: aa103252e5918143bb1dacb19e87e47bb1784e83
Jakob Ackermann пре 4 година
родитељ
комит
6122520bf5

+ 3 - 3
services/web/app/src/Features/Subscription/RecurlyWrapper.js

@@ -439,9 +439,9 @@ const RecurlyWrapper = {
   apiRequest(options, callback) {
   apiRequest(options, callback) {
     options.url = RecurlyWrapper.apiUrl + '/' + options.url
     options.url = RecurlyWrapper.apiUrl + '/' + options.url
     options.headers = {
     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',
       Accept: 'application/xml',
       'Content-Type': 'application/xml; charset=utf-8',
       'Content-Type': 'application/xml; charset=utf-8',
       'X-Api-Version': Settings.apis.recurly.apiVersion,
       'X-Api-Version': Settings.apis.recurly.apiVersion,

+ 10 - 5
services/web/scripts/regenerate_duplicate_referral_ids.js

@@ -70,11 +70,16 @@ async function processBatch(_, users) {
     await rewriteDuplicates(uniqueReferalIdsInBatch)
     await rewriteDuplicates(uniqueReferalIdsInBatch)
     return
     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) {
     if (VERBOSE_LOGGING) {
       console.log('Got duplicates from running count.')
       console.log('Got duplicates from running count.')
     }
     }

+ 1 - 1
services/web/test/acceptance/src/ApiClsiTests.js

@@ -16,7 +16,7 @@ const { expect } = require('chai')
 const request = require('./helpers/request')
 const request = require('./helpers/request')
 const Settings = require('@overleaf/settings')
 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({
 const authed_request = request.defaults({
   headers: {
   headers: {
     Authorization: `Basic ${auth}`,
     Authorization: `Basic ${auth}`,

+ 1 - 4
services/web/test/acceptance/src/RegenerateDuplicateReferralIdsTests.js

@@ -108,10 +108,7 @@ describe('RegenerateDuplicateReferralIds', function () {
 
 
   it('should do the correct operations', function () {
   it('should do the correct operations', function () {
     let { stderr: stdErr, stdout: stdOut } = result
     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)
     stdOut = stdOut.split('\n').filter(filterOutput)
     expect(stdErr).to.deep.equal([
     expect(stdErr).to.deep.equal([
       `Completed batch ending ${firstBatch[BATCH_SIZE - 1]}`,
       `Completed batch ending ${firstBatch[BATCH_SIZE - 1]}`,