Esempio n. 1
0
 /**
  * @brief Returns uploadname as link for geeky scan
  * @param $job_pk
  * @return uploadname
  **/
 function getUploadNameForGeekyScan($job_pk)
 {
     $row = $this->showJobsDao->getDataForASingleJob($job_pk);
     if (empty($row["job_upload_fk"])) {
         return '';
     }
     if (empty($row['jq_pk'])) {
         return _("Job history record is no longer available");
     }
     /* get the upload filename */
     $uploadFileName = htmlspecialchars($this->uploadDao->getUpload($row['job_upload_fk'])->getFilename());
     if (empty($uploadFileName)) {
         /* upload has been deleted so try to get the job name from the original upload job record */
         $jobName = $this->showJobsDao->getJobName($row["job_upload_fk"]);
         $uploadFileName = "Deleted " . $jobName;
     }
     $uploadtree_pk = -1;
     /* Find the uploadtree_pk for this upload so that it can be used in the browse link */
     try {
         $uploadtree_pk = $this->uploadDao->getUploadParent($row['job_upload_fk']);
     } catch (Exception $e) {
         echo $e->getMessage(), "\n";
     }
     /* upload file name link to browse */
     $uploadNameLink = "<a title='Click to browse this upload' href='" . Traceback_uri() . "?mod=browse&upload=" . $row['job_upload_fk'] . "&item=" . $uploadtree_pk . "'>" . $uploadFileName . "</a>";
     return $uploadNameLink;
 }
Esempio n. 2
0
 /**
  * @brief Returns geeky scan details about the jobqueue item
  * @param $job_pk
  * @return Return job and jobqueue record data in an html table.
  **/
 function showJobDB($job_pk)
 {
     global $container;
     /** @var DbManager */
     $dbManager = $container->get('db.manager');
     $statementName = __METHOD__ . "ShowJobDBforjob";
     $dbManager->prepare($statementName, "SELECT *, jq_endtime-jq_starttime as elapsed FROM jobqueue LEFT JOIN job ON job.job_pk = jobqueue.jq_job_fk WHERE jobqueue.jq_pk = \$1");
     $result = $dbManager->execute($statementName, array($job_pk));
     $row = $dbManager->fetchArray($result);
     $dbManager->freeResult($result);
     if (!empty($row["job_upload_fk"])) {
         /* get the upload filename */
         $statementName = __METHOD__ . "upload_filenameforShowJobDB";
         $dbManager->prepare($statementName, "select upload_filename, upload_desc from upload where upload_pk =\$1");
         $uploadresult = $dbManager->execute($statementName, array($row['job_upload_fk']));
         $uploadRow = $dbManager->fetchArray($uploadresult);
         if (empty($uploadRow)) {
             /* upload has been deleted so try to get the job name from the original upload job record */
             $jobName = $this->showJobsDao->getJobName($row["job_upload_fk"]);
             $upload_filename = "Deleted " . $jobName;
             $upload_desc = '';
         } else {
             $upload_filename = $uploadRow['upload_filename'];
             $upload_desc = $uploadRow['upload_desc'];
         }
         $dbManager->freeResult($uploadresult);
         if (empty($row['jq_pk'])) {
             return _("Job history record is no longer available");
         }
         $uploadtree_tablename = $this->uploadDao->getUploadtreeTableName($row['job_upload_fk']);
         /* Find the uploadtree_pk for this upload so that it can be used in the browse link */
         $statementName = __METHOD__ . "uploadtreeRec";
         $uploadtreeRec = $dbManager->getSingleRow("select * from {$uploadtree_tablename} where parent is NULL and upload_fk=\$1", array($row['job_upload_fk']), $statementName);
         $uploadtree_pk = $uploadtreeRec['uploadtree_pk'];
     }
     /* upload file name link to browse */
     if (!empty($row['job_upload_fk'])) {
         $uploadTreeName = "";
         $uploadTreeName = "<a title='Click to browse this upload' href='" . Traceback_uri() . "?mod=browse&upload=" . $row['job_upload_fk'] . "&item=" . $uploadtree_pk . "'>" . $upload_filename . "</a>";
         return $uploadTreeName;
     }
 }
Esempio n. 3
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);
 }
Esempio n. 4
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)));
 }