From 1b84f005ccd947871bcabce8bf79ac19600f194d Mon Sep 17 00:00:00 2001 From: Eric Mc Sween <5454374+emcsween@users.noreply.github.com> Date: Thu, 4 Jul 2024 12:56:50 -0400 Subject: [PATCH] Merge pull request #19271 from overleaf/em-really-skip-projects-without-history Refine check for existence of history in migration script GitOrigin-RevId: 8ad5706525f5043694e516d585a7aef85a1e5566 --- .../src/Features/History/HistoryRangesSupportMigration.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/services/web/app/src/Features/History/HistoryRangesSupportMigration.js b/services/web/app/src/Features/History/HistoryRangesSupportMigration.js index c59196e38e..48de0a1b8d 100644 --- a/services/web/app/src/Features/History/HistoryRangesSupportMigration.js +++ b/services/web/app/src/Features/History/HistoryRangesSupportMigration.js @@ -8,7 +8,10 @@ const HistoryManager = require('../History/HistoryManager') const DocumentUpdaterHandler = require('../DocumentUpdater/DocumentUpdaterHandler') const DocstoreManager = require('../Docstore/DocstoreManager') const ProjectOptionsHandler = require('../Project/ProjectOptionsHandler') -const { db } = require('../../infrastructure/mongodb') +const { + db, + READ_PREFERENCE_SECONDARY, +} = require('../../infrastructure/mongodb') /** * Migrate projects based on a query. @@ -40,7 +43,7 @@ async function migrateProjects(opts = {}) { const clauses = [] // skip projects that don't have full project history - clauses.push({ 'overleaf.history': { $exists: true } }) + clauses.push({ 'overleaf.history.id': { $exists: true } }) if (projectIds != null) { clauses.push({ _id: { $in: projectIds.map(id => new ObjectId(id)) } }) @@ -62,6 +65,7 @@ async function migrateProjects(opts = {}) { const projects = db.projects .find(filter, { + readPreference: READ_PREFERENCE_SECONDARY, projection: { _id: 1, overleaf: 1 }, }) .sort({ _id: -1 })