@@ -264,6 +264,9 @@ async function searchChallenges (currentUser, criteria) {
264
264
} )
265
265
}
266
266
267
+ if ( criteria . useSchedulingAPI ) {
268
+ boolQuery . push ( { match_phrase : { 'legacy.useSchedulingAPI' : criteria . useSchedulingAPI } } )
269
+ }
267
270
if ( criteria . forumId ) {
268
271
boolQuery . push ( { match_phrase : { 'legacy.forumId' : criteria . forumId } } )
269
272
}
@@ -673,7 +676,8 @@ searchChallenges.schema = {
673
676
taskIsAssigned : Joi . boolean ( ) ,
674
677
taskMemberId : Joi . string ( ) ,
675
678
events : Joi . array ( ) . items ( Joi . string ( ) ) ,
676
- includeAllEvents : Joi . boolean ( ) . default ( true )
679
+ includeAllEvents : Joi . boolean ( ) . default ( true ) ,
680
+ useSchedulingAPI : Joi . boolean ( )
677
681
} ) . unknown ( true )
678
682
}
679
683
@@ -967,7 +971,8 @@ createChallenge.schema = {
967
971
directProjectId : Joi . number ( ) . integer ( ) ,
968
972
screeningScorecardId : Joi . number ( ) . integer ( ) ,
969
973
reviewScorecardId : Joi . number ( ) . integer ( ) ,
970
- isTask : Joi . boolean ( )
974
+ isTask : Joi . boolean ( ) ,
975
+ useSchedulingAPI : Joi . boolean ( )
971
976
} ) ,
972
977
task : Joi . object ( ) . keys ( {
973
978
isTask : Joi . boolean ( ) . default ( false ) ,
@@ -1222,6 +1227,9 @@ async function update (currentUser, challengeId, data, isFull) {
1222
1227
if ( _ . get ( challenge , 'typeId' ) && _ . get ( data , 'typeId' ) && _ . get ( challenge , 'typeId' ) !== _ . get ( data , 'typeId' ) ) {
1223
1228
throw new errors . ForbiddenError ( 'Cannot change typeId' )
1224
1229
}
1230
+ if ( _ . get ( challenge , 'legacy.useSchedulingAPI' ) && _ . get ( data , 'legacy.useSchedulingAPI' ) && _ . get ( challenge , 'legacy.useSchedulingAPI' ) !== _ . get ( data , 'legacy.useSchedulingAPI' ) ) {
1231
+ throw new errors . ForbiddenError ( 'Cannot change legacy.useSchedulingAPI' )
1232
+ }
1225
1233
1226
1234
if ( ! _ . isUndefined ( challenge . legacy ) && ! _ . isUndefined ( data . legacy ) ) {
1227
1235
_ . extend ( challenge . legacy , data . legacy )
@@ -1340,6 +1348,7 @@ async function update (currentUser, challengeId, data, isFull) {
1340
1348
data . updatedBy = currentUser . handle || currentUser . sub
1341
1349
const updateDetails = { }
1342
1350
const auditLogs = [ ]
1351
+ let phasesHaveBeenModified = false
1343
1352
_ . each ( data , ( value , key ) => {
1344
1353
let op
1345
1354
if ( key === 'metadata' ) {
@@ -1349,6 +1358,7 @@ async function update (currentUser, challengeId, data, isFull) {
1349
1358
}
1350
1359
} else if ( key === 'phases' ) {
1351
1360
if ( isDifferentPhases ( challenge [ key ] , value ) ) {
1361
+ phasesHaveBeenModified = true
1352
1362
logger . info ( 'update phases' )
1353
1363
op = '$PUT'
1354
1364
}
@@ -1590,7 +1600,9 @@ async function update (currentUser, challengeId, data, isFull) {
1590
1600
busEventPayload . billingAccountId = billingAccountId
1591
1601
}
1592
1602
await helper . postBusEvent ( constants . Topics . ChallengeUpdated , busEventPayload )
1593
-
1603
+ if ( phasesHaveBeenModified === true && _ . get ( challenge , 'legacy.useSchedulingAPI' ) ) {
1604
+ await helper . postBusEvent ( config . SCHEDULING_TOPIC , { id : challengeId } )
1605
+ }
1594
1606
if ( challenge . phases && challenge . phases . length > 0 ) {
1595
1607
challenge . currentPhase = challenge . phases . slice ( ) . reverse ( ) . find ( phase => phase . isOpen )
1596
1608
challenge . endDate = helper . calculateChallengeEndDate ( challenge )
@@ -1656,7 +1668,8 @@ function sanitizeChallenge (challenge) {
1656
1668
'directProjectId' ,
1657
1669
'screeningScorecardId' ,
1658
1670
'reviewScorecardId' ,
1659
- 'isTask'
1671
+ 'isTask' ,
1672
+ 'useSchedulingAPI'
1660
1673
] )
1661
1674
}
1662
1675
if ( challenge . metadata ) {
@@ -1711,7 +1724,8 @@ fullyUpdateChallenge.schema = {
1711
1724
directProjectId : Joi . number ( ) . integer ( ) ,
1712
1725
screeningScorecardId : Joi . number ( ) . integer ( ) ,
1713
1726
reviewScorecardId : Joi . number ( ) . integer ( ) ,
1714
- isTask : Joi . boolean ( )
1727
+ isTask : Joi . boolean ( ) ,
1728
+ useSchedulingAPI : Joi . boolean ( )
1715
1729
} ) . unknown ( true ) ,
1716
1730
task : Joi . object ( ) . keys ( {
1717
1731
isTask : Joi . boolean ( ) . default ( false ) ,
@@ -1806,7 +1820,8 @@ partiallyUpdateChallenge.schema = {
1806
1820
confidentialityType : Joi . string ( ) . default ( config . DEFAULT_CONFIDENTIALITY_TYPE ) ,
1807
1821
directProjectId : Joi . number ( ) ,
1808
1822
forumId : Joi . number ( ) . integer ( ) ,
1809
- isTask : Joi . boolean ( )
1823
+ isTask : Joi . boolean ( ) ,
1824
+ useSchedulingAPI : Joi . boolean ( )
1810
1825
} ) . unknown ( true ) ,
1811
1826
task : Joi . object ( ) . keys ( {
1812
1827
isTask : Joi . boolean ( ) . default ( false ) ,
0 commit comments