@@ -204,6 +204,29 @@ public function scalarAdd($args)
204
204
$ notifyComponent = MidasLoader::loadComponent ('ThresholdNotification ' , 'tracker ' );
205
205
$ notifyComponent ->scheduleNotifications ($ scalar , $ notifications );
206
206
}
207
+ if (!$ official )
208
+ {
209
+ $ jobModel = MidasLoader::loadModel ('Job ' , 'scheduler ' );
210
+ $ settingModel = MidasLoader::loadModel ('Setting ' );
211
+ $ nHours = $ settingModel ->getValueByName ('tempScalarTtl ' , 'tracker ' );
212
+ if (!$ nHours )
213
+ {
214
+ $ nHours = 24 ; //default to 24 hours
215
+ }
216
+ foreach ($ notifications as $ notification )
217
+ {
218
+ $ job = MidasLoader::newDao ('JobDao ' , 'scheduler ' );
219
+ $ job ->setTask ('TASK_TRACKER_DELETE_TEMP_SCALAR ' );
220
+ $ job ->setPriority (1 );
221
+ $ job ->setRunOnlyOnce (1 );
222
+ $ job ->setFireTime (date ('Y-m-j G:i:s ' , strtotime ('+ ' .$ nHours .' hours ' )));
223
+ $ job ->setTimeInterval (0 );
224
+ $ job ->setStatus (SCHEDULER_JOB_STATUS_TORUN );
225
+ $ job ->setCreatorId ($ user ->getKey ());
226
+ $ job ->setParams (JsonComponent::encode (array ('scalarId ' => $ scalar ->getKey ())));
227
+ $ jobModel ->save ($ job );
228
+ }
229
+ }
207
230
return $ scalar ;
208
231
}
209
232
@@ -229,6 +252,16 @@ public function resultsUploadJson($args)
229
252
$ user = $ this ->_getUser ($ args );
230
253
231
254
$ official = !array_key_exists ('unofficial ' , $ args );
255
+ if (!$ official )
256
+ {
257
+ $ jobModel = MidasLoader::loadModel ('Job ' , 'scheduler ' );
258
+ $ settingModel = MidasLoader::loadModel ('Setting ' );
259
+ $ nHours = $ settingModel ->getValueByName ('tempScalarTtl ' , 'tracker ' );
260
+ if (!$ nHours )
261
+ {
262
+ $ nHours = 24 ; //default to 24 hours
263
+ }
264
+ }
232
265
233
266
// Unofficial submissions only require read access to the community
234
267
$ community = $ communityModel ->load ($ args ['communityId ' ]);
@@ -362,6 +395,22 @@ public function resultsUploadJson($args)
362
395
$ notifyComponent = MidasLoader::loadComponent ('ThresholdNotification ' , 'tracker ' );
363
396
$ notifyComponent ->scheduleNotifications ($ scalar , $ notifications );
364
397
}
398
+ if (!$ official )
399
+ {
400
+ foreach ($ notifications as $ notification )
401
+ {
402
+ $ job = MidasLoader::newDao ('JobDao ' , 'scheduler ' );
403
+ $ job ->setTask ('TASK_TRACKER_DELETE_TEMP_SCALAR ' );
404
+ $ job ->setPriority (1 );
405
+ $ job ->setRunOnlyOnce (1 );
406
+ $ job ->setFireTime (date ('Y-m-j G:i:s ' , strtotime ('+ ' .$ nHours .' hours ' )));
407
+ $ job ->setTimeInterval (0 );
408
+ $ job ->setStatus (SCHEDULER_JOB_STATUS_TORUN );
409
+ $ job ->setCreatorId ($ user ->getKey ());
410
+ $ job ->setParams (JsonComponent::encode (array ('scalarId ' => $ scalar ->getKey ())));
411
+ $ jobModel ->save ($ job );
412
+ }
413
+ }
365
414
}
366
415
}
367
416
}
0 commit comments