mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-30 00:45:40 -05:00
ee85d948e2
GitOrigin-RevId: ef2ef77e26df59d1af3df6dc664e284d3c70102d
44 lines
1.3 KiB
JavaScript
44 lines
1.3 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
// Clear timestamps which don't have any corresponding history ops
|
|
// usage: scripts/flush_all.js <limit>
|
|
|
|
import logger from '@overleaf/logger'
|
|
import * as RedisManager from '../app/js/RedisManager.js'
|
|
|
|
const argv = process.argv.slice(2)
|
|
const limit = parseInt(argv[0], 10) || null
|
|
|
|
// find all dangling timestamps and clear them
|
|
async function main() {
|
|
logger.info(
|
|
{ limit },
|
|
'running redis scan for project timestamps, this may take a while'
|
|
)
|
|
const projectIdsWithFirstOpTimestamps =
|
|
await RedisManager.promises.getProjectIdsWithFirstOpTimestamps(limit)
|
|
const totalTimestamps = projectIdsWithFirstOpTimestamps.length
|
|
logger.info(
|
|
{ totalTimestamps },
|
|
'scan completed, now clearing dangling timestamps'
|
|
)
|
|
let clearedTimestamps = 0
|
|
let processed = 0
|
|
for (const projectId of projectIdsWithFirstOpTimestamps) {
|
|
const result = await RedisManager.promises.clearDanglingFirstOpTimestamp(
|
|
projectId
|
|
)
|
|
processed++
|
|
clearedTimestamps += result
|
|
if (processed % 1000 === 0) {
|
|
logger.info(
|
|
{ processed, totalTimestamps, clearedTimestamps },
|
|
'clearing timestamps'
|
|
)
|
|
}
|
|
}
|
|
logger.info({ processed, totalTimestamps, clearedTimestamps }, 'completed')
|
|
process.exit(0)
|
|
}
|
|
|
|
main()
|