mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 06:03:45 +01:00
Merge pull request #10998 from overleaf/em-upgrade-mongo-document-updater
Upgrade Mongo driver in document updater GitOrigin-RevId: e3c4d86bbcf86dcf16fdfdbfab2aaf0d8eb1037c
This commit is contained in:
@@ -4,25 +4,14 @@ const rclient = require('@overleaf/redis-wrapper').createClient(
|
||||
Settings.redis.documentupdater
|
||||
)
|
||||
const keys = Settings.redis.documentupdater.key_schema
|
||||
const ProjectFlusher = require('app/js/ProjectFlusher')
|
||||
const DocumentManager = require('app/js/DocumentManager')
|
||||
const ProjectFlusher = require('../app/js/ProjectFlusher')
|
||||
const DocumentManager = require('../app/js/DocumentManager')
|
||||
const { mongoClient, db, ObjectId } = require('../app/js/mongodb')
|
||||
const util = require('util')
|
||||
const flushAndDeleteDocWithLock = util.promisify(
|
||||
DocumentManager.flushAndDeleteDocWithLock
|
||||
)
|
||||
|
||||
const { MongoClient, ObjectId } = require('mongodb')
|
||||
|
||||
const clientPromise = MongoClient.connect(
|
||||
Settings.mongo.url,
|
||||
Settings.mongo.options
|
||||
)
|
||||
|
||||
const db = {}
|
||||
clientPromise.then(client => {
|
||||
db.docs = client.db().collection('docs')
|
||||
})
|
||||
|
||||
async function fixDocsWithMissingProjectIds(dockeys, options) {
|
||||
const docIds = ProjectFlusher._extractIds(dockeys)
|
||||
for (const docId of docIds) {
|
||||
@@ -86,15 +75,13 @@ async function findAndProcessDocs(options) {
|
||||
} while (cursor !== '0')
|
||||
}
|
||||
|
||||
clientPromise.then(client => {
|
||||
findAndProcessDocs({ limit: 1000, dryRun: process.env.DRY_RUN !== 'false' })
|
||||
.then(result => {
|
||||
rclient.quit()
|
||||
client.close()
|
||||
console.log('DONE')
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.error(error)
|
||||
process.exit(1)
|
||||
})
|
||||
})
|
||||
findAndProcessDocs({ limit: 1000, dryRun: process.env.DRY_RUN !== 'false' })
|
||||
.then(result => {
|
||||
rclient.quit()
|
||||
mongoClient.close()
|
||||
console.log('DONE')
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.error(error)
|
||||
process.exit(1)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user