mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-13 21:53:43 +01:00
Merge pull request #28481 from overleaf/oa-access-secondary-mongo
[web] Prefer secondary Mongo for get emails script GitOrigin-RevId: 84cf1d23b056a4d4a738f1783059d2309997d912
This commit is contained in:
@@ -2,7 +2,11 @@ import { scriptRunner } from './lib/ScriptRunner.mjs'
|
||||
import fs from 'node:fs'
|
||||
import readline from 'node:readline'
|
||||
import minimist from 'minimist'
|
||||
import { db, ObjectId } from '../app/src/infrastructure/mongodb.js'
|
||||
import {
|
||||
db,
|
||||
ObjectId,
|
||||
READ_PREFERENCE_SECONDARY,
|
||||
} from '../app/src/infrastructure/mongodb.js'
|
||||
|
||||
/**
|
||||
* This script extracts user emails given a list of newline separated IDs
|
||||
@@ -64,14 +68,18 @@ function parseArgs() {
|
||||
|
||||
async function processBatch(idBatch, writeStream) {
|
||||
try {
|
||||
const cursor = db.users
|
||||
.find({
|
||||
const cursor = db.users.find(
|
||||
{
|
||||
_id: { $in: idBatch },
|
||||
})
|
||||
.project({
|
||||
_id: 0,
|
||||
email: 1,
|
||||
})
|
||||
},
|
||||
{
|
||||
projection: {
|
||||
_id: 0,
|
||||
email: 1,
|
||||
},
|
||||
readPreference: READ_PREFERENCE_SECONDARY,
|
||||
}
|
||||
)
|
||||
|
||||
for await (const doc of cursor) {
|
||||
if (doc.email) {
|
||||
|
||||
Reference in New Issue
Block a user