Merge pull request #34884 from overleaf/em-already-in-your-library

Library import: flag entries that are already in the user's library

GitOrigin-RevId: f3c92fb59283631e1a9e78d2e08a3a365981df45
This commit is contained in:
Eric Mc Sween
2026-06-26 08:07:21 +00:00
committed by Copybot
parent 75f7f82a3f
commit 4fb8608908
4 changed files with 45 additions and 5 deletions
@@ -0,0 +1,36 @@
import Helpers from './lib/helpers.mjs'
const tags = ['saas']
// Partial indexes so docs without a given match token are not indexed. They
// back the batch duplicate-detection query in findMatchingReferences.
const newIndexes = [
{
key: { userId: 1, 'matchTokens.doi': 1 },
name: 'userId_1_matchTokens.doi_1',
partialFilterExpression: { 'matchTokens.doi': { $exists: true } },
},
{
key: { userId: 1, 'matchTokens.authorTitleYear': 1 },
name: 'userId_1_matchTokens.authorTitleYear_1',
partialFilterExpression: {
'matchTokens.authorTitleYear': { $exists: true },
},
},
]
const migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.libraryReferences, newIndexes)
}
const rollback = async client => {
const { db } = client
await Helpers.dropIndexesFromCollection(db.libraryReferences, newIndexes)
}
export default {
tags,
migrate,
rollback,
}