示例#1
0
 public static final function GetLargestWaitTimeOfContest($contest_id, $showAllRuns = false)
 {
     // Build SQL statement.
     $sql = "SELECT * FROM Runs WHERE contest_id = ? AND status != 'ready' ORDER BY run_id ASC LIMIT 1";
     $val = array($contest_id);
     global $conn;
     $rs = $conn->GetRow($sql, $val);
     if (count($rs) === 0) {
         return null;
     }
     $run = new Runs($rs);
     return array($run, time() - strtotime($run->getTime()));
 }
 public function actionSaveWPQuest($id)
 {
     $run = Runs::model()->findByPk($id);
     $plataforma = Platforms::model()->findByPk($run['id_platform']);
     // array com os testes default
     $defaultTestsKeys = array(1.1, 1.2, 1.3, 2.1, 2.2, 2.3, 2.4, 5.1, 5.2, 5.3, 5.4, 7.3, 7.4, 7.5, 7.6, 7.7, 8.1, 8.199999999999999, 8.300000000000001, 8.4, 8.5);
     // pegar os ID,s selecionados
     // verificar inde tem virgula
     // montar uma lista com todos os compostos
     // replicar esse codigo abaixo
     // consertar essa gambiarra URGENTE
     foreach ($defaultTestsKeys as $key) {
         $testRuns = TestCase::model()->findBySql('SELECT * FROM `test_case` where num = ' . $key);
         if ($testRuns["id"] != "") {
             $id_testcase = $testRuns["id"];
             // echo $testRuns["id"]."<br/>";
             $id_runs = $id;
             $connection = Yii::app()->db;
             $command = $connection->createCommand("INSERT INTO `test_run`(`id_runs`, `id_test_case`, `status`) VALUES (" . $id_runs . "," . $testRuns["id"] . ",0)");
             $rowCount = $command->execute();
         }
     }
     $this->redirect(array('view', 'id' => $id));
 }
 /**
  * Invalidates relevant caches on run rejudge
  *
  * @param RunsDAO $run
  */
 public static function invalidateCacheOnRejudge(Runs $run)
 {
     try {
         // Expire details of the run
         Cache::deleteFromCache(Cache::RUN_ADMIN_DETAILS, $run->getRunId());
         $contest = ContestsDAO::getByPK($run->getContestId());
         // Now we need to invalidate problem stats
         $problem = ProblemsDAO::getByPK($run->getProblemId());
         if (!is_null($problem)) {
             // Invalidar cache stats
             Cache::deleteFromCache(Cache::PROBLEM_STATS, $problem->getAlias());
         }
     } catch (Exception $e) {
         // We did our best effort to invalidate the cache...
         self::$log->warn('Failed to invalidate cache on Rejudge, skipping: ');
         self::$log->warn($e);
     }
 }
 public function QuantidadeTotal($id)
 {
     $testRuns = TestRun::model()->findAllByAttributes(array('id_runs' => $id));
     $quantidadeTotal = count($testRuns);
     $quanti = Runs::QuantidadePass($id);
     $quantifail = Runs::QuantidadeFail($id);
     //$result = $quanti + $quantifail;
     $porcentagem = floor(($quanti + $quantifail) / ($quantidadeTotal == 0 ? 1 : $quantidadeTotal) * 100);
     return $porcentagem;
 }