@@ -340,24 +340,22 @@ class ChallengeDomain extends CoreOperations<Challenge, CreateChallengeInput> {
340
340
await legacyPhaseDomain . updateProjectPhase ( {
341
341
projectPhaseId : phase . projectPhaseId ,
342
342
phaseStatusId : newStatus ,
343
- fixedStartTime : moment ( phase . fixedStartTime ) . format (
344
- "yyyy-MM-DD HH:mm:ss"
345
- )
346
- ? moment ( v5Equivalent . scheduledStartDate ) . format (
347
- "yyyy-MM-DD HH:mm:ss"
348
- )
349
- : undefined ,
343
+ ...( phaseOrder === 0 ? {
344
+ fixedStartTime : moment ( phase . fixedStartTime ) . format (
345
+ "yyyy-MM-DD HH:mm:ss"
346
+ )
347
+ ? moment ( v5Equivalent . scheduledStartDate ) . format (
348
+ "yyyy-MM-DD HH:mm:ss"
349
+ )
350
+ : undefined ,
351
+ } : { } ) ,
350
352
scheduledStartTime : moment (
351
353
v5Equivalent . scheduledStartDate
352
354
) . format ( "yyyy-MM-DD HH:mm:ss" ) ,
353
355
scheduledEndTime : moment ( v5Equivalent . scheduledEndDate ) . format (
354
356
"yyyy-MM-DD HH:mm:ss"
355
357
) ,
356
358
duration : v5Equivalent . duration * 1000 ,
357
- ...( isBeingActivated &&
358
- newStatus == constants . PhaseStatusTypes . Open
359
- ? { actualStartTime : moment ( ) . format ( "yyyy-MM-DD HH:mm:ss" ) }
360
- : { } ) ,
361
359
} ) ;
362
360
} else {
363
361
console . log ( `number of ${ phaseName } does not match` ) ;
@@ -964,7 +962,8 @@ class ChallengeDomain extends CoreOperations<Challenge, CreateChallengeInput> {
964
962
const createdByUserId = 22838965 ; // TODO: Extract from interceptors
965
963
const updatedByUserId = 22838965 ; // TODO: Extract from interceptors
966
964
967
- if ( ! input ?. legacyId ) {
965
+ if ( ! input ?. legacyId && input ?. status && input ?. status !== ChallengeStatuses . New ) {
966
+ console . log ( `Legacy ID does not exist. Creating challenge in legacy...` ) ;
968
967
const { track, subTrack, isTask, technologies } =
969
968
legacyMapper . mapTrackAndType (
970
969
input . trackId as string ,
@@ -1003,6 +1002,7 @@ class ChallengeDomain extends CoreOperations<Challenge, CreateChallengeInput> {
1003
1002
input . legacyId = legacyChallengeId as number ;
1004
1003
}
1005
1004
1005
+ console . log ( `Updating challenge in legacy...` ) ;
1006
1006
if ( input ?. legacyId ) {
1007
1007
const legacyId = input . legacyId ;
1008
1008
const legacyChallenge = await legacyChallengeDomain . getLegacyChallenge ( {
@@ -1251,6 +1251,7 @@ class ChallengeDomain extends CoreOperations<Challenge, CreateChallengeInput> {
1251
1251
}
1252
1252
}
1253
1253
}
1254
+ console . log ( "Challenge updated successfully in legacy" ) ;
1254
1255
1255
1256
// toEntity parses the below properties thus we should now stringify them again
1256
1257
// for (const key of ["phases",
@@ -1261,16 +1262,14 @@ class ChallengeDomain extends CoreOperations<Challenge, CreateChallengeInput> {
1261
1262
// "prizeSets"]) {
1262
1263
// _.set(input, key, JSON.stringify(_.get(input, key)))
1263
1264
// }
1264
- // console.log('------ before save --------');
1265
+ console . log ( '------ before save --------' ) ;
1265
1266
1266
1267
// console.log(input);
1267
1268
console . log ( _ . omit ( input , [ "id" ] ) ) ;
1268
1269
1269
1270
const challengeList = await super . update ( scanCriteria , {
1270
- ..._ . omit ( input , [ "id" ] ) ,
1271
- ...( input . prizeSets
1272
- ? { prizeSets : input . prizeSets . map ( ( ps ) => JSON . stringify ( ps ) ) }
1273
- : { } ) ,
1271
+ ..._ . omit ( input , [ "id" , ...( ! input . legacyId ? [ "legacyId" ] : [ ] ) ] ) ,
1272
+ // prizeSets: input.prizeSets.map((ps) => JSON.stringify(ps)),
1274
1273
} ) ;
1275
1274
1276
1275
console . log ( "------ after save --------" ) ;
0 commit comments