Przeglądaj źródła

Merge pull request #9963 from overleaf/msm-option-skip-audit

[scripts] option to skip user migration in `migrate_audit_logs`

GitOrigin-RevId: 738465abeca0d95a493bc3d805f4822dd29760a2
Alf Eaton 3 lat temu
rodzic
commit
609483b4f0
1 zmienionych plików z 12 dodań i 8 usunięć
  1. 12 8
      services/web/scripts/migrate_audit_logs.js

+ 12 - 8
services/web/scripts/migrate_audit_logs.js

@@ -12,6 +12,7 @@ async function main(options) {
     dryRun: process.env.DRY_RUN !== 'false',
     projectId: process.env.PROJECT_ID,
     userId: process.env.USER_ID,
+    skipUsersMigration: process.env.SKIP_USERS_MIGRATION === 'true',
     writeConcurrency: parseInt(process.env.WRITE_CONCURRENCY, 10) || 10,
     letUserDoubleCheckInputsFor: parseInt(
       process.env.LET_USER_DOUBLE_CHECK_INPUTS_FOR || 10 * 1000,
@@ -44,14 +45,16 @@ async function main(options) {
     }
     await processUsersBatch([user], options)
   } else {
-    await batchedUpdate(
-      'users',
-      { auditLog: { $exists: true } },
-      async (_, users) => {
-        await processUsersBatch(users, options)
-      },
-      { _id: 1, auditLog: 1 }
-    )
+    if (!options.skipUsersMigration) {
+      await batchedUpdate(
+        'users',
+        { auditLog: { $exists: true } },
+        async (_, users) => {
+          await processUsersBatch(users, options)
+        },
+        { _id: 1, auditLog: 1 }
+      )
+    }
 
     // most projects are processed after its owner has been processed, but only those
     // users with an existing `auditLog` have been taken into consideration, leaving
@@ -132,6 +135,7 @@ async function letUserDoubleCheckInputs(options) {
     VERBOSE_LOGGING: process.env.VERBOSE_LOGGING,
     BATCH_LAST_ID: process.env.BATCH_LAST_ID,
     BATCH_RANGE_END: process.env.BATCH_RANGE_END,
+    SKIP_USERS_MIGRATION: process.env.SKIP_USERS_MIGRATION,
   }
   console.error('Options:', JSON.stringify(allOptions, null, 2))
   console.error(