Skip to content

Commit 73c233f

Browse files
Merge branch 'develop' of https://github.com/topcoder-platform/challenge-api into develop
2 parents 73852ff + 746dfc7 commit 73c233f

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

docs/swagger.yaml

+22
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,28 @@ paths:
174174
type: array
175175
items:
176176
type: string
177+
- name: includeAllTags
178+
in: query
179+
description: >-
180+
Require all provided tags to be present on a challenge for a match
181+
required: false
182+
default: true
183+
type: boolean
184+
- name: events
185+
in: query
186+
description: >-
187+
Filter by multiple event keys (ie: tco21)
188+
required: false
189+
type: array
190+
items:
191+
type: number
192+
- name: includeAllEvents
193+
in: query
194+
description: >-
195+
Require all provided events to be present on a challenge for a match
196+
required: false
197+
default: true
198+
type: boolean
177199
- name: projectId
178200
in: query
179201
description: 'Filter by v5 project id, exact match.'

src/services/ChallengeService.js

+16-2
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ async function searchChallenges (currentUser, criteria) {
154154
_.forIn(_.omit(criteria, ['types', 'tracks', 'typeIds', 'trackIds', 'type', 'name', 'trackId', 'typeId', 'description', 'page', 'perPage', 'tag',
155155
'group', 'groups', 'memberId', 'ids', 'createdDateStart', 'createdDateEnd', 'updatedDateStart', 'updatedDateEnd', 'startDateStart', 'startDateEnd', 'endDateStart', 'endDateEnd',
156156
'tags', 'registrationStartDateStart', 'registrationStartDateEnd', 'currentPhaseName', 'submissionStartDateStart', 'submissionStartDateEnd',
157-
'registrationEndDateStart', 'registrationEndDateEnd', 'submissionEndDateStart', 'submissionEndDateEnd',
157+
'registrationEndDateStart', 'registrationEndDateEnd', 'submissionEndDateStart', 'submissionEndDateEnd', 'includeAllEvents', 'events',
158158
'forumId', 'track', 'reviewType', 'confidentialityType', 'directProjectId', 'sortBy', 'sortOrder', 'isLightweight', 'isTask', 'taskIsAssigned', 'taskMemberId']), (value, key) => {
159159
if (!_.isUndefined(value)) {
160160
const filter = { match_phrase: {} }
@@ -274,6 +274,18 @@ async function searchChallenges (currentUser, criteria) {
274274
}
275275
}
276276

277+
if (criteria.events) {
278+
if (criteria.includeAllEvents) {
279+
for (const e of criteria.events) {
280+
boolQuery.push({ match_phrase: { 'events.key': e } })
281+
}
282+
} else {
283+
for (const e of criteria.events) {
284+
shouldQuery.push({ match: { 'events.key': e } })
285+
}
286+
}
287+
}
288+
277289
const mustNotQuery = []
278290

279291
let groupsToFilter = []
@@ -579,7 +591,9 @@ searchChallenges.schema = {
579591
ids: Joi.array().items(Joi.optionalId()).unique().min(1),
580592
isTask: Joi.boolean(),
581593
taskIsAssigned: Joi.boolean(),
582-
taskMemberId: Joi.string()
594+
taskMemberId: Joi.string(),
595+
events: Joi.array().items(Joi.number()),
596+
includeAllEvents: Joi.boolean().default(true)
583597
})
584598
}
585599

0 commit comments

Comments
 (0)