mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 09:09:36 +02:00
* [web] cleanup archived split-test assignments from user record on login Co-authored-by: Anna Claire Fields <anna.fields@overleaf.com> * [migrations] purge archived split tests from all users Co-authored-by: Anna Claire Fields <anna.fields@overleaf.com> * [web] add missing mock and update snapshot test * [web] gracefully access db.users.splitTests --------- Co-authored-by: Anna Claire Fields <anna.fields@overleaf.com> GitOrigin-RevId: bd185074a402556d7b7c812208cf834dd52b27a5
31 lines
755 B
JavaScript
31 lines
755 B
JavaScript
import { db } from './lib/mongodb.mjs'
|
|
import { batchedUpdate } from '@overleaf/mongo-utils/batchedUpdate.js'
|
|
|
|
const tags = ['saas', 'server-ce', 'server-pro']
|
|
|
|
const migrate = async () => {
|
|
const splitTests = await db.splittests.find().toArray()
|
|
const toCleanup = {}
|
|
for (const splitTest of splitTests) {
|
|
if (splitTest.archived) {
|
|
toCleanup[`splitTests.${splitTest.name}`] = 1
|
|
}
|
|
}
|
|
// Take the easy route and unset all the archived split tests on all the users with any split test assignment.
|
|
await batchedUpdate(
|
|
db.users,
|
|
{ splitTests: { $exists: true } },
|
|
{ $unset: toCleanup }
|
|
)
|
|
}
|
|
|
|
const rollback = async () => {
|
|
// The data is gone. Nothing to revert to.
|
|
}
|
|
|
|
export default {
|
|
tags,
|
|
migrate,
|
|
rollback,
|
|
}
|