mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #2833 from overleaf/jpa-ns-replace-spellcheck-languages
[script] replace_spellcheck_lng: use projectIds as additional filter GitOrigin-RevId: 8813dd883c81174b7078b6af7c1dd148381fce4e
This commit is contained in:
parent
63c155b1e8
commit
a0809e1d85
1 changed files with 28 additions and 2 deletions
|
@ -1,4 +1,22 @@
|
||||||
const { db } = require('../app/src/infrastructure/mongojs')
|
// Run like this:
|
||||||
|
// node ... --projectIds ./path/to/file/with/one/projectId/in/each/line
|
||||||
|
|
||||||
|
const fs = require('fs')
|
||||||
|
const { db, ObjectId } = require('../app/src/infrastructure/mongojs')
|
||||||
|
|
||||||
|
const minimist = require('minimist')
|
||||||
|
|
||||||
|
const argv = minimist(process.argv.slice(2))
|
||||||
|
const commit = argv.commit !== undefined
|
||||||
|
|
||||||
|
if (!argv.projectIds) {
|
||||||
|
console.error('--projectIds flag is missing')
|
||||||
|
process.exit(100)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!commit) {
|
||||||
|
console.log('DOING DRY RUN. TO SAVE CHANGES PASS --commit')
|
||||||
|
}
|
||||||
|
|
||||||
const languages = [
|
const languages = [
|
||||||
'am',
|
'am',
|
||||||
|
@ -22,8 +40,16 @@ const languages = [
|
||||||
'fi'
|
'fi'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
const projectIds = fs
|
||||||
|
.readFileSync(argv.projectIds, { encoding: 'utf-8' })
|
||||||
|
.split('\n')
|
||||||
|
.filter(Boolean)
|
||||||
|
|
||||||
function main(callback) {
|
function main(callback) {
|
||||||
const query = { spellCheckLanguage: { $in: languages } }
|
const query = {
|
||||||
|
_id: { $in: projectIds.map(ObjectId) },
|
||||||
|
spellCheckLanguage: { $in: languages }
|
||||||
|
}
|
||||||
db.projects.update(
|
db.projects.update(
|
||||||
query,
|
query,
|
||||||
{ $set: { spellCheckLanguage: '' } },
|
{ $set: { spellCheckLanguage: '' } },
|
||||||
|
|
Loading…
Reference in a new issue