mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 17:19:37 +02:00
[web] last infrastructure conversions GitOrigin-RevId: ad1aff9b7df0610ed0303157d9e2c8032f32c02b
41 lines
966 B
JavaScript
41 lines
966 B
JavaScript
import { scriptRunner } from './lib/ScriptRunner.mjs'
|
|
import { db } from '../app/src/infrastructure/mongodb.mjs'
|
|
import minimist from 'minimist'
|
|
const argv = minimist(process.argv.slice(2))
|
|
|
|
async function resetTutorials() {
|
|
const commit = argv.commit !== undefined
|
|
|
|
const users = await db.users
|
|
.find(
|
|
{
|
|
'completedTutorials.rolling-compile-image-changed.state': 'completed',
|
|
},
|
|
{ readPreference: 'secondaryPreferred' }
|
|
)
|
|
.toArray()
|
|
|
|
if (!commit) {
|
|
console.log(
|
|
`would have removed rolling-compile-image-changed tutorial for ${users.length} users`
|
|
)
|
|
return
|
|
}
|
|
|
|
await db.users.updateMany(
|
|
{ _id: { $in: users.map(user => user._id) } },
|
|
{
|
|
$unset: { 'completedTutorials.rolling-compile-image-changed': '' },
|
|
}
|
|
)
|
|
console.log(`updated ${users.length} users`)
|
|
}
|
|
|
|
try {
|
|
await scriptRunner(resetTutorials)
|
|
process.exit(0)
|
|
} catch (error) {
|
|
console.error(error)
|
|
process.exit(1)
|
|
}
|