Skip to content

fix: challenge timeline template curd #483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ workflows:
branches:
only:
- develop
- fix/challenge-timelines-edit-routes

# Production builds are exectuted only on tagged commits to the
# master branch.
Expand Down
1 change: 0 additions & 1 deletion src/common/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -1287,6 +1287,5 @@ module.exports = {
sendSelfServiceNotification,
getMemberByHandle,
submitZendeskRequest,
getMemberById,
updateSelfServiceProjectInfo
}
6 changes: 3 additions & 3 deletions src/controllers/ChallengeTimelineTemplateController.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async function createChallengeTimelineTemplate (req, res) {
* @param {Object} res the response
*/
async function getChallengeTimelineTemplate (req, res) {
const result = await service.getChallengeTimelineTemplate(req.params.challengeTypeTimelineTemplateId)
const result = await service.getChallengeTimelineTemplate(req.params.challengeTimelineTemplateId)
res.send(result)
}

Expand All @@ -42,7 +42,7 @@ async function getChallengeTimelineTemplate (req, res) {
* @param {Object} res the response
*/
async function fullyUpdateChallengeTimelineTemplate (req, res) {
const result = await service.fullyUpdateChallengeTimelineTemplate(req.params.challengeTypeTimelineTemplateId, req.body)
const result = await service.fullyUpdateChallengeTimelineTemplate(req.params.challengeTimelineTemplateId, req.body)
res.send(result)
}

Expand All @@ -52,7 +52,7 @@ async function fullyUpdateChallengeTimelineTemplate (req, res) {
* @param {Object} res the response
*/
async function deleteChallengeTimelineTemplate (req, res) {
const result = await service.deleteChallengeTimelineTemplate(req.params.challengeTypeTimelineTemplateId)
const result = await service.deleteChallengeTimelineTemplate(req.params.challengeTimelineTemplateId)
res.send(result)
}

Expand Down
9 changes: 4 additions & 5 deletions src/services/ChallengeTimelineTemplateService.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ searchChallengeTimelineTemplates.schema = {
*/
async function unsetDefaultTimelineTemplate (typeId, trackId) {
const records = await searchChallengeTimelineTemplates({ typeId, trackId, isDefault: true })
if (records.length === 0) {
if (records.total === 0) {
return
}
for (const record of records) {
for (const record of records.result) {
await fullyUpdateChallengeTimelineTemplate(record.id, { ...record, isDefault: false })
}
}
Expand All @@ -61,7 +61,7 @@ async function unsetDefaultTimelineTemplate (typeId, trackId) {
async function createChallengeTimelineTemplate (data) {
// check duplicate
const records = await searchChallengeTimelineTemplates(data)
if (records.length > 0) {
if (records.total > 0) {
throw new errors.ConflictError('The challenge type timeline template is already defined.')
}
// check exists
Expand Down Expand Up @@ -109,7 +109,6 @@ getChallengeTimelineTemplate.schema = {
*/
async function fullyUpdateChallengeTimelineTemplate (challengeTimelineTemplateId, data) {
const record = await helper.getById('ChallengeTimelineTemplate', challengeTimelineTemplateId)

if (record.typeId === data.typeId &&
record.trackId === data.trackId &&
record.timelineTemplateId === data.timelineTemplateId &&
Expand All @@ -120,7 +119,7 @@ async function fullyUpdateChallengeTimelineTemplate (challengeTimelineTemplateId

// check duplicate
const records = await searchChallengeTimelineTemplates(data)
if (records.length > 0) {
if (records.total > 0) {
throw new errors.ConflictError('The challenge type timeline template is already defined.')
}
// check exists
Expand Down