mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #8402 from overleaf/msm-history-conversion-script
[web] Allow running history conversion script on single project GitOrigin-RevId: 799d0a00e2ebabe6c7bbfd6bdbdb58a6025ce53f
This commit is contained in:
parent
825c06a3b4
commit
34bc2ac9ec
1 changed files with 32 additions and 23 deletions
|
@ -14,8 +14,10 @@ process.env.BATCH_SIZE = BATCH_SIZE
|
||||||
process.env.MONGO_SOCKET_TIMEOUT =
|
process.env.MONGO_SOCKET_TIMEOUT =
|
||||||
parseInt(process.env.MONGO_SOCKET_TIMEOUT, 10) || 3600000
|
parseInt(process.env.MONGO_SOCKET_TIMEOUT, 10) || 3600000
|
||||||
|
|
||||||
const { ReadPreference } = require('mongodb')
|
const PROJECT_ID = process.env.PROJECT_ID
|
||||||
const { db } = require('../../app/src/infrastructure/mongodb')
|
|
||||||
|
const { ReadPreference, ObjectId } = require('mongodb')
|
||||||
|
const { db, waitForDb } = require('../../app/src/infrastructure/mongodb')
|
||||||
const { promiseMapWithLimit } = require('../../app/src/util/promises')
|
const { promiseMapWithLimit } = require('../../app/src/util/promises')
|
||||||
const { batchedUpdate } = require('../helpers/batchedUpdate')
|
const { batchedUpdate } = require('../helpers/batchedUpdate')
|
||||||
const ProjectHistoryController = require('../../modules/admin-panel/app/src/ProjectHistoryController')
|
const ProjectHistoryController = require('../../modules/admin-panel/app/src/ProjectHistoryController')
|
||||||
|
@ -29,6 +31,7 @@ console.log({
|
||||||
MAX_FAILURES,
|
MAX_FAILURES,
|
||||||
USE_QUERY_HINT,
|
USE_QUERY_HINT,
|
||||||
RETRY_FAILED,
|
RETRY_FAILED,
|
||||||
|
PROJECT_ID,
|
||||||
})
|
})
|
||||||
|
|
||||||
const RESULT = {
|
const RESULT = {
|
||||||
|
@ -187,28 +190,34 @@ async function anyDocHistoryIndexExists(project) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const projection = {
|
if (PROJECT_ID) {
|
||||||
_id: 1,
|
await waitForDb()
|
||||||
overleaf: 1,
|
const project = await db.projects.findOne({ _id: ObjectId(PROJECT_ID) })
|
||||||
|
await processProject(project)
|
||||||
|
} else {
|
||||||
|
const projection = {
|
||||||
|
_id: 1,
|
||||||
|
overleaf: 1,
|
||||||
|
}
|
||||||
|
const options = {}
|
||||||
|
if (USE_QUERY_HINT) {
|
||||||
|
options.hint = { _id: 1 }
|
||||||
|
}
|
||||||
|
await batchedUpdate(
|
||||||
|
'projects',
|
||||||
|
{
|
||||||
|
$and: [
|
||||||
|
{ 'overleaf.history.display': { $ne: true } },
|
||||||
|
{ 'overleaf.history.id': { $exists: true } },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
processBatch,
|
||||||
|
projection,
|
||||||
|
options
|
||||||
|
)
|
||||||
|
console.log('Final')
|
||||||
|
console.log(RESULT)
|
||||||
}
|
}
|
||||||
const options = {}
|
|
||||||
if (USE_QUERY_HINT) {
|
|
||||||
options.hint = { _id: 1 }
|
|
||||||
}
|
|
||||||
await batchedUpdate(
|
|
||||||
'projects',
|
|
||||||
{
|
|
||||||
$and: [
|
|
||||||
{ 'overleaf.history.display': { $ne: true } },
|
|
||||||
{ 'overleaf.history.id': { $exists: true } },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
processBatch,
|
|
||||||
projection,
|
|
||||||
options
|
|
||||||
)
|
|
||||||
console.log('Final')
|
|
||||||
console.log(RESULT)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Upgrading history is not atomic, if we quit out mid-initialisation
|
// Upgrading history is not atomic, if we quit out mid-initialisation
|
||||||
|
|
Loading…
Reference in a new issue