mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-25 02:00:10 +02:00
Merge pull request #24536 from overleaf/revert-24444-td-inactive-project-index
Revert "Update inactive project deactivation index" GitOrigin-RevId: cc6788af5fcb652fdb1eaeefe7f10c5bc1afa910
This commit is contained in:
@@ -5,6 +5,7 @@ const DocumentUpdaterHandler = require('../DocumentUpdater/DocumentUpdaterHandle
|
||||
const ProjectGetter = require('../Project/ProjectGetter')
|
||||
const ProjectUpdateHandler = require('../Project/ProjectUpdateHandler')
|
||||
const { Project } = require('../../models/Project')
|
||||
const { ObjectId } = require('mongodb-legacy')
|
||||
const Modules = require('../../infrastructure/Modules')
|
||||
const { READ_PREFERENCE_SECONDARY } = require('../../infrastructure/mongodb')
|
||||
const { callbackifyAll } = require('@overleaf/promise-utils')
|
||||
@@ -61,6 +62,8 @@ const InactiveProjectManager = {
|
||||
projects = await Project.find({
|
||||
lastOpened: { $not: { $gt: oldProjectDate } },
|
||||
})
|
||||
.where('_id')
|
||||
.lt(ObjectId.createFromTime(oldProjectDate / 1000))
|
||||
.where('active')
|
||||
.equals(true)
|
||||
.select('_id')
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
|
||||
import Helpers from './lib/helpers.mjs'
|
||||
|
||||
const tags = ['server-ce', 'server-pro', 'saas']
|
||||
|
||||
const oldIndex = {
|
||||
key: {
|
||||
lastOpened: 1,
|
||||
},
|
||||
name: 'lastOpened_1',
|
||||
}
|
||||
|
||||
const newIndex = {
|
||||
key: {
|
||||
lastOpened: 1,
|
||||
},
|
||||
name: 'active_true_lastOpened_1',
|
||||
partialFilterExpression: { active: true },
|
||||
}
|
||||
|
||||
const migrate = async client => {
|
||||
const { db } = client
|
||||
|
||||
await Helpers.dropIndexesFromCollection(db.projects, [oldIndex])
|
||||
await Helpers.addIndexesToCollection(db.projects, [newIndex])
|
||||
}
|
||||
|
||||
const rollback = async client => {
|
||||
const { db } = client
|
||||
|
||||
try {
|
||||
await Helpers.dropIndexesFromCollection(db.projects, [newIndex])
|
||||
await Helpers.addIndexesToCollection(db.projects, [oldIndex])
|
||||
} catch (err) {
|
||||
console.error('Something went wrong rolling back the migrations', err)
|
||||
}
|
||||
}
|
||||
export default {
|
||||
tags,
|
||||
migrate,
|
||||
rollback,
|
||||
}
|
||||
Reference in New Issue
Block a user