@@ -45,10 +45,10 @@ searchChallengeTimelineTemplates.schema = {
4545 */
4646async 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) {
6161async 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 */
110110async 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