mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
[misc] apply review feedback on naming functions and parameters
Co-Authored-By: Simon Detheridge <s@sd.ai>
This commit is contained in:
parent
4996f8bbcd
commit
d69c29e4dc
3 changed files with 22 additions and 18 deletions
|
@ -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
|
||||
)
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue