@@ -204,6 +204,29 @@ public function scalarAdd($args)
204204 $ notifyComponent = MidasLoader::loadComponent ('ThresholdNotification ' , 'tracker ' );
205205 $ notifyComponent ->scheduleNotifications ($ scalar , $ notifications );
206206 }
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+ }
207230 return $ scalar ;
208231 }
209232
@@ -229,6 +252,16 @@ public function resultsUploadJson($args)
229252 $ user = $ this ->_getUser ($ args );
230253
231254 $ 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+ }
232265
233266 // Unofficial submissions only require read access to the community
234267 $ community = $ communityModel ->load ($ args ['communityId ' ]);
@@ -362,6 +395,22 @@ public function resultsUploadJson($args)
362395 $ notifyComponent = MidasLoader::loadComponent ('ThresholdNotification ' , 'tracker ' );
363396 $ notifyComponent ->scheduleNotifications ($ scalar , $ notifications );
364397 }
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+ }
365414 }
366415 }
367416 }
0 commit comments