mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 14:13:43 +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,28 +4,17 @@ const rclient = require('@overleaf/redis-wrapper').createClient(
|
||||
Settings.redis.documentupdater
|
||||
)
|
||||
const keys = Settings.redis.documentupdater.key_schema
|
||||
const ProjectFlusher = require('app/js/ProjectFlusher')
|
||||
const RedisManager = require('app/js/RedisManager')
|
||||
const ProjectFlusher = require('../app/js/ProjectFlusher')
|
||||
const RedisManager = require('../app/js/RedisManager')
|
||||
const { mongoClient, db, ObjectId } = require('../app/js/mongodb')
|
||||
const util = require('util')
|
||||
const getDoc = util.promisify((projectId, docId, cb) =>
|
||||
RedisManager.getDoc(projectId, docId, (err, ...args) => cb(err, args))
|
||||
)
|
||||
const removeDocFromMemory = util.promisify(RedisManager.removeDocFromMemory)
|
||||
const { MongoClient, ObjectId } = require('mongodb')
|
||||
|
||||
const clientPromise = MongoClient.connect(
|
||||
Settings.mongo.url,
|
||||
Settings.mongo.options
|
||||
)
|
||||
|
||||
const summary = { totalDocs: 0, deletedDocs: 0, skippedDocs: 0 }
|
||||
|
||||
const db = {}
|
||||
clientPromise.then(client => {
|
||||
db.docs = client.db().collection('docs')
|
||||
db.projects = client.db().collection('projects')
|
||||
})
|
||||
|
||||
async function removeDeletedDocs(dockeys, options) {
|
||||
const docIds = ProjectFlusher._extractIds(dockeys)
|
||||
for (const docId of docIds) {
|
||||
@@ -159,15 +148,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