diff --git a/services/docstore/app/js/DocArchiveManager.js b/services/docstore/app/js/DocArchiveManager.js index 7b4bf4611f..7a062bc739 100644 --- a/services/docstore/app/js/DocArchiveManager.js +++ b/services/docstore/app/js/DocArchiveManager.js @@ -36,7 +36,7 @@ module.exports = { async function archiveAllDocs(projectId) { while (true) { - const docs = await MongoManager.getNNonArchivedProjectDocs( + const docs = await MongoManager.getNonArchivedProjectDocs( projectId, ARCHIVE_BATCH_SIZE ) @@ -106,12 +106,12 @@ async function unArchiveAllDocs(projectId) { while (true) { let docs if (settings.docstore.keepSoftDeletedDocsArchived) { - docs = await MongoManager.getNNonDeletedArchivedProjectDocs( + docs = await MongoManager.getNonDeletedArchivedProjectDocs( projectId, UN_ARCHIVE_BATCH_SIZE ) } else { - docs = await MongoManager.getNArchivedProjectDocs( + docs = await MongoManager.getArchivedProjectDocs( projectId, UN_ARCHIVE_BATCH_SIZE ) diff --git a/services/docstore/app/js/MongoManager.js b/services/docstore/app/js/MongoManager.js index e62f7e6eaf..385245c9e3 100644 --- a/services/docstore/app/js/MongoManager.js +++ b/services/docstore/app/js/MongoManager.js @@ -64,29 +64,33 @@ module.exports = MongoManager = { db.docs.find(query, queryOptions).toArray(callback) }, - getNArchivedProjectDocs(project_id, n, callback) { + getArchivedProjectDocs(project_id, maxResults, callback) { const query = { project_id: ObjectId(project_id.toString()), inS3: true } - db.docs.find(query, { projection: { _id: 1 }, limit: n }).toArray(callback) + db.docs + .find(query, { projection: { _id: 1 }, limit: maxResults }) + .toArray(callback) }, - getNNonArchivedProjectDocs(project_id, n, callback) { + getNonArchivedProjectDocs(project_id, maxResults, callback) { const query = { project_id: ObjectId(project_id.toString()), inS3: { $ne: true } } - db.docs.find(query, { limit: n }).toArray(callback) + db.docs.find(query, { limit: maxResults }).toArray(callback) }, - getNNonDeletedArchivedProjectDocs(project_id, n, callback) { + getNonDeletedArchivedProjectDocs(project_id, maxResults, callback) { const query = { project_id: ObjectId(project_id.toString()), deleted: { $ne: true }, inS3: true } - db.docs.find(query, { projection: { _id: 1 }, limit: n }).toArray(callback) + db.docs + .find(query, { projection: { _id: 1 }, limit: maxResults }) + .toArray(callback) }, upsertIntoDocCollection(project_id, doc_id, updates, callback) { diff --git a/services/docstore/test/unit/js/DocArchiveManagerTests.js b/services/docstore/test/unit/js/DocArchiveManagerTests.js index e902622db1..41fe75a8df 100644 --- a/services/docstore/test/unit/js/DocArchiveManagerTests.js +++ b/services/docstore/test/unit/js/DocArchiveManagerTests.js @@ -116,24 +116,24 @@ describe('DocArchiveManager', function () { deleteObject: sinon.stub().resolves() } - const getNNonArchivedProjectDocs = sinon.stub() - getNNonArchivedProjectDocs + const getNonArchivedProjectDocs = sinon.stub() + getNonArchivedProjectDocs .onCall(0) .resolves(mongoDocs.filter((doc) => !doc.inS3)) - getNNonArchivedProjectDocs.onCall(1).resolves([]) + getNonArchivedProjectDocs.onCall(1).resolves([]) - const getNArchivedProjectDocs = sinon.stub() - getNArchivedProjectDocs.onCall(0).resolves(archivedDocs) - getNArchivedProjectDocs.onCall(1).resolves([]) + const getArchivedProjectDocs = sinon.stub() + getArchivedProjectDocs.onCall(0).resolves(archivedDocs) + getArchivedProjectDocs.onCall(1).resolves([]) MongoManager = { promises: { markDocAsArchived: sinon.stub().resolves(), upsertIntoDocCollection: sinon.stub().resolves(), getProjectsDocs: sinon.stub().resolves(mongoDocs), - getNNonDeletedArchivedProjectDocs: getNArchivedProjectDocs, - getNNonArchivedProjectDocs, - getNArchivedProjectDocs, + getNonDeletedArchivedProjectDocs: getArchivedProjectDocs, + getNonArchivedProjectDocs, + getArchivedProjectDocs, findDoc: sinon.stub().rejects(new Errors.NotFoundError()), destroyDoc: sinon.stub().resolves() }