Skip to content

Commit c10a0b9

Browse files
Merge branch 'develop' of https://github.com/topcoder-platform/challenge-api into develop
2 parents 8961316 + 1820010 commit c10a0b9

File tree

5 files changed

+28
-7
lines changed

5 files changed

+28
-7
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ workflows:
7272
- develop
7373
- fix/challenge-timelines-edit-routes
7474
- test/performance-profile
75+
- ss-bughunt
7576

7677
# Production builds are exectuted only on tagged commits to the
7778
# master branch.

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,10 @@ You can find sample `.env` files inside the `/docs` directory.
129129
npm run services:up
130130
```
131131

132-
4. ♻ Update following two parts:
133-
- https://github.com/topcoder-platform/challenge-api/blob/develop/src/models/Challenge.js#L116
132+
4. ♻ Update following three parts:
133+
- https://github.com/topcoder-platform/challenge-api/blob/develop/src/models/Challenge.js#L140
134+
`throughput: 'ON_DEMAND',` should be updated to `throughput:{ read: 4, write: 2 },`
135+
- https://github.com/topcoder-platform/challenge-api/blob/develop/src/models/Phase.js#L33
134136
`throughput: 'ON_DEMAND',` should be updated to `throughput:{ read: 4, write: 2 },`
135137
- https://github.com/topcoder-platform/challenge-api/blob/develop/config/default.js#L27-L28
136138

config/default.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ module.exports = {
7373
OBSERVER_ROLE_ID: process.env.OBSERVER_ROLE_ID || '2a4dc376-a31c-4d00-b173-13934d89e286',
7474
CLIENT_MANAGER_ROLE_ID: process.env.OBSERVER_ROLE_ID || '9b2f1905-8128-42da-85df-ed64410f4781',
7575

76+
// topgear billing accounts
77+
TOPGEAR_BILLING_ACCOUNTS_ID: process.env.TOPGEAR_BILLING_ACCOUNTS_ID ? process.env.TOPGEAR_BILLING_ACCOUNTS_ID.split(',') : [],
78+
7679
// health check timeout in milliseconds
7780
HEALTH_CHECK_TIMEOUT: process.env.HEALTH_CHECK_TIMEOUT || 3000,
7881

src/common/helper.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -494,14 +494,15 @@ async function createSelfServiceProject (name, description, type, token) {
494494
const res = await axios.post(url, projectObj, { headers: { Authorization: `Bearer ${token}` } })
495495
const projectId = _.get(res, 'data.id')
496496
const phaseUrl = `${config.PROJECTS_API_URL}/${projectId}/phases`
497-
const phaseStartDate = Date.now()
498-
const phaseEndDate = Date.now()
497+
const phaseStartDate = new Date()
498+
const phaseEndDate = new Date()
499499
phaseEndDate.setMonth(phaseEndDate.getMonth() + 3)
500500
const phaseObj = {
501501
name: 'project main phase',
502502
description: 'default 90-day phase generated by self-service APIs',
503-
startDate: phaseStartDate,
504-
endDate: phaseEndDate
503+
startDate: phaseStartDate.getTime(),
504+
endDate: phaseEndDate.getTime(),
505+
status: 'draft'
505506
}
506507
await axios.post(phaseUrl, phaseObj, { headers: { Authorization: `Bearer ${token}` } })
507508
return projectId

src/services/ChallengeService.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ async function searchChallenges (currentUser, criteria) {
166166
if (criteria.types) {
167167
for (const t of criteria.types) {
168168
const typeSearchRes = await ChallengeTypeService.searchChallengeTypes({ abbreviation: t })
169-
if (typeSearchRes.total > 0) {
169+
if (typeSearchRes.total > 0 || criteria.types.length === 1) {
170170
includedTypeIds.push(_.get(typeSearchRes, 'result[0].id'))
171171
}
172172
}
@@ -1446,6 +1446,9 @@ async function update (currentUser, challengeId, data, isFull) {
14461446
// helper.ensureNoDuplicateOrNullElements(data.gitRepoURLs, 'gitRepoURLs')
14471447

14481448
const challenge = await helper.getById('Challenge', challengeId)
1449+
if (challenge.task && (challenge.status === constants.challengeStatuses.Completed || data.status === constants.challengeStatuses.Completed || _.get(data, 'winners.length') > 0 || _.get(challenge, 'winners.length') > 0)) {
1450+
_.unset(data, 'task')
1451+
}
14491452
let dynamicDescription = _.cloneDeep(data.description || challenge.description)
14501453
if (challenge.legacy.selfService && data.metadata && data.metadata.length > 0) {
14511454
for (const entry of data.metadata) {
@@ -1488,6 +1491,17 @@ async function update (currentUser, challengeId, data, isFull) {
14881491
_.set(data, 'billing.billingAccountId', billingAccountId)
14891492
_.set(data, 'billing.markup', markup || 0)
14901493
}
1494+
if (billingAccountId && _.includes(config.TOPGEAR_BILLING_ACCOUNTS_ID, _.toString(billingAccountId))) {
1495+
if (_.isEmpty(data.metadata)) {
1496+
data.metadata = []
1497+
}
1498+
if (!_.find(data.metadata, e => e.name === 'postMortemRequired')) {
1499+
data.metadata.push({
1500+
name: 'postMortemRequired',
1501+
value: 'false'
1502+
})
1503+
}
1504+
}
14911505
if (data.status) {
14921506
if (data.status === constants.challengeStatuses.Active) {
14931507
if (!_.get(challenge, 'legacy.pureV5Task') && !_.get(challenge, 'legacy.pureV5') && _.isUndefined(_.get(challenge, 'legacyId'))) {

0 commit comments

Comments
 (0)