mirror of
https://github.com/overleaf/overleaf.git
synced 2025-01-23 21:21:44 +00:00
Merge pull request #8335 from overleaf/msm-fix-reset-rev-script
Fixed `reset_incorrect_doc_revision.js` script GitOrigin-RevId: 59448881e372ca7ca6f3b50f76cab5476279a1ab
This commit is contained in:
parent
3238694daa
commit
c5f93bedea
2 changed files with 17 additions and 11 deletions
|
@ -3,6 +3,7 @@ const { db, waitForDb } = require('../../app/src/infrastructure/mongodb')
|
|||
|
||||
const BATCH_DESCENDING = process.env.BATCH_DESCENDING === 'true'
|
||||
const BATCH_SIZE = parseInt(process.env.BATCH_SIZE, 10) || 1000
|
||||
const VERBOSE_LOGGING = process.env.VERBOSE_LOGGING === 'true'
|
||||
let BATCH_LAST_ID
|
||||
if (process.env.BATCH_LAST_ID) {
|
||||
BATCH_LAST_ID = ObjectId(process.env.BATCH_LAST_ID)
|
||||
|
@ -78,11 +79,15 @@ async function batchedUpdate(
|
|||
) {
|
||||
maxId = nextBatch[nextBatch.length - 1]._id
|
||||
updated += nextBatch.length
|
||||
console.log(
|
||||
`Running update on batch with ids ${JSON.stringify(
|
||||
nextBatch.map(entry => entry._id)
|
||||
)}`
|
||||
)
|
||||
if (VERBOSE_LOGGING) {
|
||||
console.log(
|
||||
`Running update on batch with ids ${JSON.stringify(
|
||||
nextBatch.map(entry => entry._id)
|
||||
)}`
|
||||
)
|
||||
} else {
|
||||
console.error(`Running update on batch ending ${maxId}`)
|
||||
}
|
||||
|
||||
if (typeof update === 'function') {
|
||||
await update(collection, nextBatch)
|
||||
|
|
|
@ -1,8 +1,3 @@
|
|||
const { ObjectId } = require('mongodb')
|
||||
const { db, waitForDb } = require('../../app/src/infrastructure/mongodb')
|
||||
const { batchedUpdate } = require('../helpers/batchedUpdate')
|
||||
const { promiseMapWithLimit } = require('../../app/src/util/promises')
|
||||
|
||||
const DRY_RUN = process.env.DRY_RUN !== 'false'
|
||||
const PROJECT_ID = process.env.PROJECT_ID
|
||||
const VERBOSE_LOGGING = process.env.VERBOSE_LOGGING === 'true'
|
||||
|
@ -11,6 +6,12 @@ const WRITE_CONCURRENCY = parseInt(process.env.WRITE_CONCURRENCY, 10) || 50
|
|||
const BATCH_SIZE = parseInt(process.env.BATCH_SIZE, 10) || 500
|
||||
// persist fallback in order to keep batchedUpdate in-sync
|
||||
process.env.BATCH_SIZE = BATCH_SIZE
|
||||
process.env.VERBOSE_LOGGING = VERBOSE_LOGGING
|
||||
|
||||
const { ObjectId } = require('mongodb')
|
||||
const { db, waitForDb } = require('../../app/src/infrastructure/mongodb')
|
||||
const { batchedUpdate } = require('../helpers/batchedUpdate')
|
||||
const { promiseMapWithLimit } = require('../../app/src/util/promises')
|
||||
|
||||
const count = {
|
||||
projects: 0,
|
||||
|
@ -39,7 +40,7 @@ async function main() {
|
|||
} else {
|
||||
await batchedUpdate(
|
||||
'projects',
|
||||
{ 'overleaf.history.display': { $ne: false } },
|
||||
{ 'overleaf.history.display': { $ne: true } },
|
||||
processBatch,
|
||||
projection,
|
||||
options
|
||||
|
|
Loading…
Reference in a new issue