Skip to content

Commit 4118334

Browse files
authored
Merge pull request #484 from topcoder-platform/develop
fix: timeline-templates endpoint
2 parents 680d357 + 6582d21 commit 4118334

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

.circleci/config.yml

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ workflows:
7070
branches:
7171
only:
7272
- develop
73+
- fix/challenge-timelines-edit-routes
7374

7475
# Production builds are exectuted only on tagged commits to the
7576
# master branch.

src/common/helper.js

-1
Original file line numberDiff line numberDiff line change
@@ -1287,6 +1287,5 @@ module.exports = {
12871287
sendSelfServiceNotification,
12881288
getMemberByHandle,
12891289
submitZendeskRequest,
1290-
getMemberById,
12911290
updateSelfServiceProjectInfo
12921291
}

src/controllers/ChallengeTimelineTemplateController.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ async function createChallengeTimelineTemplate (req, res) {
3232
* @param {Object} res the response
3333
*/
3434
async function getChallengeTimelineTemplate (req, res) {
35-
const result = await service.getChallengeTimelineTemplate(req.params.challengeTypeTimelineTemplateId)
35+
const result = await service.getChallengeTimelineTemplate(req.params.challengeTimelineTemplateId)
3636
res.send(result)
3737
}
3838

@@ -42,7 +42,7 @@ async function getChallengeTimelineTemplate (req, res) {
4242
* @param {Object} res the response
4343
*/
4444
async function fullyUpdateChallengeTimelineTemplate (req, res) {
45-
const result = await service.fullyUpdateChallengeTimelineTemplate(req.params.challengeTypeTimelineTemplateId, req.body)
45+
const result = await service.fullyUpdateChallengeTimelineTemplate(req.params.challengeTimelineTemplateId, req.body)
4646
res.send(result)
4747
}
4848

@@ -52,7 +52,7 @@ async function fullyUpdateChallengeTimelineTemplate (req, res) {
5252
* @param {Object} res the response
5353
*/
5454
async function deleteChallengeTimelineTemplate (req, res) {
55-
const result = await service.deleteChallengeTimelineTemplate(req.params.challengeTypeTimelineTemplateId)
55+
const result = await service.deleteChallengeTimelineTemplate(req.params.challengeTimelineTemplateId)
5656
res.send(result)
5757
}
5858

src/services/ChallengeTimelineTemplateService.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ searchChallengeTimelineTemplates.schema = {
4545
*/
4646
async function unsetDefaultTimelineTemplate (typeId, trackId) {
4747
const records = await searchChallengeTimelineTemplates({ typeId, trackId, isDefault: true })
48-
if (records.length === 0) {
48+
if (records.total === 0) {
4949
return
5050
}
51-
for (const record of records) {
51+
for (const record of records.result) {
5252
await fullyUpdateChallengeTimelineTemplate(record.id, { ...record, isDefault: false })
5353
}
5454
}
@@ -61,7 +61,7 @@ async function unsetDefaultTimelineTemplate (typeId, trackId) {
6161
async function createChallengeTimelineTemplate (data) {
6262
// check duplicate
6363
const records = await searchChallengeTimelineTemplates(data)
64-
if (records.length > 0) {
64+
if (records.total > 0) {
6565
throw new errors.ConflictError('The challenge type timeline template is already defined.')
6666
}
6767
// check exists
@@ -109,7 +109,6 @@ getChallengeTimelineTemplate.schema = {
109109
*/
110110
async function fullyUpdateChallengeTimelineTemplate (challengeTimelineTemplateId, data) {
111111
const record = await helper.getById('ChallengeTimelineTemplate', challengeTimelineTemplateId)
112-
113112
if (record.typeId === data.typeId &&
114113
record.trackId === data.trackId &&
115114
record.timelineTemplateId === data.timelineTemplateId &&
@@ -120,7 +119,7 @@ async function fullyUpdateChallengeTimelineTemplate (challengeTimelineTemplateId
120119

121120
// check duplicate
122121
const records = await searchChallengeTimelineTemplates(data)
123-
if (records.length > 0) {
122+
if (records.total > 0) {
124123
throw new errors.ConflictError('The challenge type timeline template is already defined.')
125124
}
126125
// check exists

0 commit comments

Comments
 (0)