mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 06:03:45 +01:00
Delete 3 migration scripts for compile-timeouts (#18163)
Co-authored-by: Jakob Ackermann <jakob.ackermann@overleaf.com> GitOrigin-RevId: 2d66052994159b6d902b807f02488095d65562e1
This commit is contained in:
committed by
Copybot
co-authored by
Jakob Ackermann
parent
6a6f155029
commit
a26c655220
@@ -1,61 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const minimist = require('minimist')
|
||||
const {
|
||||
db,
|
||||
READ_PREFERENCE_SECONDARY,
|
||||
waitForDb,
|
||||
} = require('../app/src/infrastructure/mongodb')
|
||||
const { batchedUpdate } = require('./helpers/batchedUpdate')
|
||||
|
||||
async function logCount() {
|
||||
const count60s = await db.users.countDocuments(
|
||||
{ 'features.compileTimeout': { $lte: 60, $ne: 20 } },
|
||||
{ readPreference: READ_PREFERENCE_SECONDARY }
|
||||
)
|
||||
console.log(`Found ${count60s} users with compileTimeout <= 60s && != 20s`)
|
||||
const count20s = await db.users.countDocuments(
|
||||
{ 'features.compileTimeout': 20 },
|
||||
{ readPreference: READ_PREFERENCE_SECONDARY }
|
||||
)
|
||||
console.log(`Found ${count20s} users with compileTimeout == 20s`)
|
||||
}
|
||||
|
||||
const main = async ({ COMMIT, SKIP_COUNT }) => {
|
||||
console.time('Script Duration')
|
||||
|
||||
await waitForDb()
|
||||
|
||||
if (!SKIP_COUNT) {
|
||||
await logCount()
|
||||
}
|
||||
|
||||
if (COMMIT) {
|
||||
const nModified = await batchedUpdate(
|
||||
'users',
|
||||
{ 'features.compileTimeout': { $lte: 60, $ne: 20 } },
|
||||
// NOTE: Always update featuresUpdatedAt to ensure the user's features synced with BigQuery
|
||||
{ $set: { 'features.compileTimeout': 20, featuresUpdatedAt: new Date() } }
|
||||
)
|
||||
console.log(`Updated ${nModified} records`)
|
||||
}
|
||||
|
||||
console.timeEnd('Script Duration')
|
||||
}
|
||||
|
||||
const setup = () => {
|
||||
const argv = minimist(process.argv.slice(2))
|
||||
const COMMIT = argv.commit !== undefined
|
||||
const SKIP_COUNT = argv['skip-count'] !== undefined
|
||||
if (!COMMIT) {
|
||||
console.warn('Doing dry run. Add --commit to commit changes')
|
||||
}
|
||||
return { COMMIT, SKIP_COUNT }
|
||||
}
|
||||
|
||||
main(setup())
|
||||
.catch(err => {
|
||||
console.error(err)
|
||||
process.exit(1)
|
||||
})
|
||||
.then(() => process.exit(0))
|
||||
-65
@@ -1,65 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const minimist = require('minimist')
|
||||
const {
|
||||
db,
|
||||
READ_PREFERENCE_SECONDARY,
|
||||
waitForDb,
|
||||
} = require('../app/src/infrastructure/mongodb')
|
||||
const { batchedUpdate } = require('./helpers/batchedUpdate')
|
||||
|
||||
// A few seconds after the previous migration script was run
|
||||
const FEATURES_UPDATED_AT = new Date('2024-04-16T12:41:00Z')
|
||||
|
||||
const query = {
|
||||
'features.compileTimeout': 20,
|
||||
$or: [
|
||||
{ featuresUpdatedAt: { $exists: false } },
|
||||
{ featuresUpdatedAt: { $lt: FEATURES_UPDATED_AT } },
|
||||
],
|
||||
}
|
||||
|
||||
async function logCount() {
|
||||
const usersToUpdate = await db.users.countDocuments(query, {
|
||||
readPreference: READ_PREFERENCE_SECONDARY,
|
||||
})
|
||||
console.log(
|
||||
`Found ${usersToUpdate} users needing their featuresUpdatedAt updated`
|
||||
)
|
||||
}
|
||||
|
||||
const main = async ({ COMMIT, SKIP_COUNT }) => {
|
||||
console.time('Script Duration')
|
||||
|
||||
await waitForDb()
|
||||
|
||||
if (!SKIP_COUNT) {
|
||||
await logCount()
|
||||
}
|
||||
|
||||
if (COMMIT) {
|
||||
const nModified = await batchedUpdate('users', query, {
|
||||
$set: { featuresUpdatedAt: FEATURES_UPDATED_AT },
|
||||
})
|
||||
console.log(`Updated ${nModified} records`)
|
||||
}
|
||||
|
||||
console.timeEnd('Script Duration')
|
||||
}
|
||||
|
||||
const setup = () => {
|
||||
const argv = minimist(process.argv.slice(2))
|
||||
const COMMIT = argv.commit !== undefined
|
||||
const SKIP_COUNT = argv['skip-count'] !== undefined
|
||||
if (!COMMIT) {
|
||||
console.warn('Doing dry run. Add --commit to commit changes')
|
||||
}
|
||||
return { COMMIT, SKIP_COUNT }
|
||||
}
|
||||
|
||||
main(setup())
|
||||
.catch(err => {
|
||||
console.error(err)
|
||||
process.exit(1)
|
||||
})
|
||||
.then(() => process.exit(0))
|
||||
@@ -1,63 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const minimist = require('minimist')
|
||||
const {
|
||||
db,
|
||||
READ_PREFERENCE_SECONDARY,
|
||||
waitForDb,
|
||||
} = require('../app/src/infrastructure/mongodb')
|
||||
const { batchedUpdate } = require('./helpers/batchedUpdate')
|
||||
|
||||
// A few seconds after the previous migration script was run
|
||||
const FEATURES_UPDATED_AT = new Date('2024-04-16T12:41:00Z')
|
||||
|
||||
const query = {
|
||||
'features.compileTimeout': 20,
|
||||
featuresUpdatedAt: FEATURES_UPDATED_AT,
|
||||
signUpDate: { $gt: FEATURES_UPDATED_AT },
|
||||
}
|
||||
|
||||
async function logCount() {
|
||||
const usersToUpdate = await db.users.countDocuments(query, {
|
||||
readPreference: READ_PREFERENCE_SECONDARY,
|
||||
})
|
||||
console.log(
|
||||
`Found ${usersToUpdate} users needing their featuresUpdatedAt removed`
|
||||
)
|
||||
}
|
||||
|
||||
const main = async ({ COMMIT, SKIP_COUNT }) => {
|
||||
console.time('Script Duration')
|
||||
|
||||
await waitForDb()
|
||||
|
||||
if (!SKIP_COUNT) {
|
||||
await logCount()
|
||||
}
|
||||
|
||||
if (COMMIT) {
|
||||
const nModified = await batchedUpdate('users', query, {
|
||||
$unset: { featuresUpdatedAt: 1 },
|
||||
})
|
||||
console.log(`Updated ${nModified} records`)
|
||||
}
|
||||
|
||||
console.timeEnd('Script Duration')
|
||||
}
|
||||
|
||||
const setup = () => {
|
||||
const argv = minimist(process.argv.slice(2))
|
||||
const COMMIT = argv.commit !== undefined
|
||||
const SKIP_COUNT = argv['skip-count'] !== undefined
|
||||
if (!COMMIT) {
|
||||
console.warn('Doing dry run. Add --commit to commit changes')
|
||||
}
|
||||
return { COMMIT, SKIP_COUNT }
|
||||
}
|
||||
|
||||
main(setup())
|
||||
.catch(err => {
|
||||
console.error(err)
|
||||
process.exit(1)
|
||||
})
|
||||
.then(() => process.exit(0))
|
||||
Reference in New Issue
Block a user