Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/controller/cve-id.controller/cve-id.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ async function getFilteredCveId (req, res, next) {
const requesterOrgUUID = await authContext.getRequesterOrgUUID(req, orgRepo)

// Create map of orgUUID to shortnames and users to simplify aggregation later
const orgs = await orgRepo.getAllOrgs()
const users = await userRepo.getAllUsers()
// Only project the fields needed for the maps to avoid fetching full documents
const orgs = await orgRepo.getAllOrgs({}, { UUID: 1, short_name: 1, _id: 0 })
const users = await userRepo.getAllUsers({}, { UUID: 1, username: 1, org_UUID: 1, _id: 0 })

const orgMap = {}
const userMap = {}
Expand Down
4 changes: 2 additions & 2 deletions src/repositories/orgRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ class OrgRepository extends BaseRepository {
return utils.isBulkDownload(shortName)
}

async getAllOrgs () {
return this.collection.find()
async getAllOrgs (options = {}, projection = {}) {
return this.collection.find({}, projection, options)
}

async deleteOneByShortName (shortName, options = {}) {
Expand Down
4 changes: 2 additions & 2 deletions src/repositories/userRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ class UserRepository extends BaseRepository {
return this.collection.findOneAndUpdate(filter, updatePayload, options)
}

async getAllUsers () {
return this.collection.find()
async getAllUsers (options = {}, projection = {}) {
return this.collection.find({}, projection, options)
}
}

Expand Down
Loading