@@ -14,6 +14,7 @@ const models = require('../models')
14
14
const HttpStatus = require ( 'http-status-codes' )
15
15
const moment = require ( 'moment' )
16
16
const phaseService = require ( './PhaseService' )
17
+ const challengeTypeService = require ( './ChallengeTypeService' )
17
18
18
19
const esClient = helper . getESClient ( )
19
20
@@ -87,7 +88,15 @@ async function searchChallenges (currentUser, criteria) {
87
88
const page = criteria . page || 1
88
89
const perPage = criteria . perPage || 20
89
90
const boolQuery = [ ]
90
- _ . forIn ( _ . omit ( criteria , [ 'name' , 'description' , 'page' , 'perPage' , 'tag' , 'group' , 'groups' , 'memberId' , 'ids' , 'createdDateStart' , 'createdDateEnd' ,
91
+
92
+ if ( criteria . type ) {
93
+ const typeSearchRes = await challengeTypeService . searchChallengeTypes ( { abbreviation : criteria . type } )
94
+ if ( typeSearchRes . total > 0 ) {
95
+ criteria . typeId = _ . get ( typeSearchRes , 'result[0].id' )
96
+ }
97
+ }
98
+
99
+ _ . forIn ( _ . omit ( criteria , [ 'type' , 'name' , 'description' , 'page' , 'perPage' , 'tag' , 'group' , 'groups' , 'memberId' , 'ids' , 'createdDateStart' , 'createdDateEnd' ,
91
100
'updatedDateStart' , 'updatedDateEnd' , 'startDateStart' , 'startDateEnd' , 'endDateStart' , 'endDateEnd' ,
92
101
'forumId' , 'track' , 'reviewType' , 'confidentialityType' , 'directProjectId' , 'sortBy' , 'sortOrder' ] ) , ( value , key ) => {
93
102
if ( ! _ . isUndefined ( value ) ) {
@@ -294,6 +303,7 @@ searchChallenges.schema = {
294
303
confidentialityType : Joi . string ( ) ,
295
304
directProjectId : Joi . number ( ) ,
296
305
typeId : Joi . optionalId ( ) ,
306
+ type : Joi . string ( ) ,
297
307
track : Joi . string ( ) ,
298
308
name : Joi . string ( ) ,
299
309
description : Joi . string ( ) ,
0 commit comments