@@ -45,10 +45,10 @@ searchChallengeTimelineTemplates.schema = {
45
45
*/
46
46
async function unsetDefaultTimelineTemplate ( typeId , trackId ) {
47
47
const records = await searchChallengeTimelineTemplates ( { typeId, trackId, isDefault : true } )
48
- if ( records . length === 0 ) {
48
+ if ( records . total === 0 ) {
49
49
return
50
50
}
51
- for ( const record of records ) {
51
+ for ( const record of records . result ) {
52
52
await fullyUpdateChallengeTimelineTemplate ( record . id , { ...record , isDefault : false } )
53
53
}
54
54
}
@@ -61,7 +61,7 @@ async function unsetDefaultTimelineTemplate (typeId, trackId) {
61
61
async function createChallengeTimelineTemplate ( data ) {
62
62
// check duplicate
63
63
const records = await searchChallengeTimelineTemplates ( data )
64
- if ( records . length > 0 ) {
64
+ if ( records . total > 0 ) {
65
65
throw new errors . ConflictError ( 'The challenge type timeline template is already defined.' )
66
66
}
67
67
// check exists
@@ -109,7 +109,6 @@ getChallengeTimelineTemplate.schema = {
109
109
*/
110
110
async function fullyUpdateChallengeTimelineTemplate ( challengeTimelineTemplateId , data ) {
111
111
const record = await helper . getById ( 'ChallengeTimelineTemplate' , challengeTimelineTemplateId )
112
-
113
112
if ( record . typeId === data . typeId &&
114
113
record . trackId === data . trackId &&
115
114
record . timelineTemplateId === data . timelineTemplateId &&
@@ -120,7 +119,7 @@ async function fullyUpdateChallengeTimelineTemplate (challengeTimelineTemplateId
120
119
121
120
// check duplicate
122
121
const records = await searchChallengeTimelineTemplates ( data )
123
- if ( records . length > 0 ) {
122
+ if ( records . total > 0 ) {
124
123
throw new errors . ConflictError ( 'The challenge type timeline template is already defined.' )
125
124
}
126
125
// check exists
0 commit comments