示例#1
0
 /**
  * @brief get data of all jobs using uploadpk
  * @return a json jobqueue data. 
  **/
 protected function getJobs($uploadPk)
 {
     $page = GetParm('page', PARM_INTEGER);
     if ($uploadPk > 0) {
         $upload_pks = array($uploadPk);
         $jobs = $this->showJobsDao->uploads2Jobs($upload_pks, $page);
     } else {
         $allusers = GetParm("allusers", PARM_INTEGER);
         $jobs = $this->showJobsDao->myJobs($allusers);
     }
     $jobsInfo = $this->showJobsDao->getJobInfo($jobs, $page);
     usort($jobsInfo, array($this, "compareJobsInfo"));
     $showJobData = $this->show($jobsInfo, $page);
     return new JsonResponse($showJobData);
 }
示例#2
0
 public function testGetJobInfo()
 {
     $this->dbManager->prepare($stmt = 'insert.jobqueue', "INSERT INTO jobqueue (jq_pk, jq_job_fk, jq_type, jq_args, jq_starttime, jq_endtime, jq_endtext, jq_end_bits, jq_schedinfo, jq_itemsprocessed)" . "VALUES (\$1, \$2, \$3, \$4,\$5, \$6,\$7,\$8,\$9,\$10)");
     $nowTime = time();
     $diffTime = 2345;
     $nomosTime = date('Y-m-d H:i:sO', $nowTime - $diffTime);
     $uploadArrayQue = array(array(8, $jobId = 1, "nomos", 1, $nomosTime, null, "Started", 0, "localhost.5963", $itemNomos = 147), array(1, $jobId, "ununpack", 1, "2015-04-21 18:29:19.23825+05:30", "2015-04-21 18:29:26.396562+05:30", "Completed", 1, null, $itemCount = 646));
     foreach ($uploadArrayQue as $uploadEntry) {
         $this->dbManager->freeResult($this->dbManager->execute($stmt, $uploadEntry));
     }
     $this->dbManager->prepare($stmt = 'insert.uploadtree_a', "INSERT INTO uploadtree_a (uploadtree_pk, parent, upload_fk, pfile_fk, ufile_mode, lft, rgt, ufile_name)" . "VALUES (\$1, \$2, \$3, \$4,\$5, \$6, \$7, \$8)");
     $uploadTreeArray = array(array(123, 121, 1, 103, 32768, 542, 543, "fckeditorcode_ie.js"), array(121, 120, 1, 0, 536888320, 537, 544, "js"), array(715, 651, 2, 607, 33188, 534, 535, "zconf.h.cmakein"), array(915, 651, 2, 606, 33188, 532, 533, "zconf.h"));
     foreach ($uploadTreeArray as $uploadEntry) {
         $this->dbManager->freeResult($this->dbManager->execute($stmt, $uploadEntry));
     }
     $this->dbManager->prepare($stmt = 'insert.jobdepends', "INSERT INTO jobdepends (jdep_jq_fk, jdep_jq_depends_fk) VALUES (\$1, \$2 )");
     $jqWithTwoDependencies = 8;
     $jobDependsArray = array(array(2, 1), array(3, 2), array(4, 2), array(5, 2), array(6, 2), array($jqWithTwoDependencies, 4), array($jqWithTwoDependencies, 4));
     foreach ($jobDependsArray as $uploadEntry) {
         $this->dbManager->freeResult($this->dbManager->execute($stmt, $uploadEntry));
     }
     $testMyJobInfo = $this->showJobsDao->getJobInfo($this->job_pks);
     assertThat($testMyJobInfo, hasKey($jobId));
     assertThat($testMyJobInfo[$jobId]['jobqueue'][$jqWithTwoDependencies]['depends'], is(arrayWithSize(2)));
     $testFilesPerSec = 0.23;
     $formattedEstimatedTime = $this->showJobsDao->getEstimatedTime($job_pk = 1, $jq_Type = "nomos", $testFilesPerSec);
     assertThat($formattedEstimatedTime, matchesPattern('/\\d+:\\d{2}:\\d{2}/'));
     $hourMinSec = explode(':', $formattedEstimatedTime);
     assertThat($hourMinSec[0] * 3600 + $hourMinSec[1] * 60 + $hourMinSec[2], is(closeTo(($itemCount - $itemNomos) / $testFilesPerSec, 0.5 + $testFilesPerSec)));
     $testGetEstimatedTime = $this->showJobsDao->getEstimatedTime($job_pk = 1, $jq_Type, 0);
     assertThat($testGetEstimatedTime, matchesPattern('/\\d+:\\d{2}:\\d{2}/'));
     $hourMinSec = explode(':', $testGetEstimatedTime);
     $tolerance = 0.5 + ($itemCount - $itemNomos) / $itemNomos + (time() - $nowTime);
     assertThat($hourMinSec[0] * 3600 + $hourMinSec[1] * 60 + $hourMinSec[2], is(closeTo(($itemCount - $itemNomos) / $itemNomos * $diffTime, $tolerance)));
     $fewFilesPerSec = 0.003;
     $formattedLongTime = $this->showJobsDao->getEstimatedTime($job_pk = 1, $jq_Type = "nomos", $fewFilesPerSec);
     assertThat($formattedLongTime, matchesPattern('/\\d+:\\d{2}:\\d{2}/'));
     $hourMinSec = explode(':', $formattedLongTime);
     assertThat($hourMinSec[0] * 3600 + $hourMinSec[1] * 60 + $hourMinSec[2], is(closeTo(($itemCount - $itemNomos) / $fewFilesPerSec, 0.5 + $fewFilesPerSec)));
 }