Merge pull request #17436 from overleaf/ab-split-test-export-cleanup

[web] Fix the split test export format and prune unwanted info

GitOrigin-RevId: 2a8ecbd738338c16fee4bf1d286e724cc25c0008
This commit is contained in:
Jessica Lawshe 2024-03-13 08:44:04 -05:00 committed by Copybot
parent 310cbe10ba
commit 408e1dccd7

View file

@ -1,7 +1,6 @@
const { SplitTest } = require('../../models/SplitTest')
const SplitTestUtils = require('./SplitTestUtils')
const OError = require('@overleaf/o-error')
const Settings = require('@overleaf/settings')
const _ = require('lodash')
const { CacheFlow } = require('cache-flow')
@ -52,7 +51,7 @@ async function getSplitTests({ name, phase, type, active, archived }) {
return await SplitTest.find(filters)
.populate('archivedBy', ['email', 'first_name', 'last_name'])
.populate('versions.author', ['email', 'first_name', 'last_name'])
.limit(100)
.limit(300)
.exec()
} catch (error) {
throw OError.tag(error, 'Failed to get split tests list')
@ -414,13 +413,13 @@ async function _saveSplitTest(splitTest) {
}
/*
* As this is only used for utility in local dev, we want to prevent this running in any other env
* since deleting all records in staging or prod would be very bad...
* As this is only used for utility in local dev environment, we should make sure this isn't run in
* any other deployment environment.
*/
function _checkEnvIsSafe(operation) {
if (Settings.splitTest.devToolbar.enabled) {
throw OError.tag(
`attempted to ${operation} all feature flags outside of local env`
if (process.env.NODE_ENV !== 'development') {
throw new OError(
`Attempted to ${operation} all feature flags outside of local env`
)
}
}
@ -432,11 +431,11 @@ async function _deleteSplitTests() {
try {
deleted = await SplitTest.deleteMany({}).exec()
} catch (error) {
throw OError.tag('Failed to delete all split tests')
throw new OError('Failed to delete all split tests')
}
if (!deleted.acknowledged) {
throw OError.tag('Error deleting split tests, split tests have not updated')
throw new OError('Error deleting split tests, split tests have not updated')
}
}