Skip to content

Commit b3e4207

Browse files
fix missing default values
1 parent 09eb7a2 commit b3e4207

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/services/ResourceService.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ async function checkAccess (currentUser, resources) {
4545
* @returns {Array} the search result
4646
*/
4747
async function getResources (currentUser, challengeId, roleId, page, perPage, sortBy, sortOrder) {
48+
page = page || 1
49+
perPage = perPage || config.DEFAULT_PAGE_SIZE
4850
if (!validateUUID(challengeId)) {
4951
throw new errors.BadRequestError(`Challenge ID ${challengeId} must be a valid v5 Challenge Id (UUID)`)
5052
}
@@ -442,8 +444,8 @@ async function listChallengesByMember (memberId, criteria) {
442444

443445
const boolQuery = []
444446
const mustQuery = []
445-
const perPage = criteria.perPage
446-
const page = criteria.page
447+
const perPage = criteria.perPage || config.DEFAULT_PAGE_SIZE
448+
const page = criteria.page || 1
447449
boolQuery.push({ match_phrase: { memberId } })
448450
if (criteria.resourceRoleId) boolQuery.push({ match_phrase: { roleId: criteria.resourceRoleId } })
449451

@@ -472,7 +474,7 @@ async function listChallengesByMember (memberId, criteria) {
472474
const esClient = await helper.getESClient()
473475
let docs
474476
try {
475-
logger.debug(`es query: ${JSON.stringify(esQuery)}`)
477+
// logger.debug(`es query: ${JSON.stringify(esQuery)}`)
476478
docs = await esClient.search(esQuery)
477479
} catch (e) {
478480
// Catch error when the ES is fresh and has no data

0 commit comments

Comments
 (0)