コード例 #1
0
 /**
  * @authorize
  * @method GET
  * @customRoute('projects/int/setup')
  */
 public function getProjectSetupPage($projectId)
 {
     $config = ConfigurationRepository::getInstance()->getActiveProjectConfiguration($projectId);
     $project = ProjectsRepository::getInstance()->getProjectById($projectId);
     if (!isset($project['id'])) {
         $replicated = SetupRepository::getInstance()->replicateProject($projectId);
         if ($replicated == 0) {
             throw new ApplicationException("Project with Id {$projectId} failed to replicate", 404);
         }
         $project = ProjectsRepository::getInstance()->getProjectById($projectId);
     }
     ProjectsRepository::getInstance()->syncProjectTestCases($projectId);
     TestCasesRepository::getInstance()->clearRemainingTestCasesOnDayEnd();
     ConfigurationRepository::getInstance()->updateParkedConfigurations();
     $testCases = TestCasesRepository::getInstance()->getProjectUnallocatedTestCasesCount($projectId);
     $project['unAllocatedTestCasesCount'] = $testCases['unAllocatedTestCasesCount'];
     $project['config'] = ConfigurationRepository::getInstance()->getActiveProjectConfiguration($projectId);
     $project['activeUsers'] = ProjectsRepository::getInstance()->getProjectAssignedUsers($projectId, $config['configId']);
     $project['currentDuration'] = ProjectsRepository::getInstance()->getProjectCurrentDuration($projectId, $config['configId']);
     $project['expiredNonFinalTestCasesCount'] = TestCasesRepository::getInstance()->getProjectExpiredNonFinalTestCasesCount($projectId, $config['configId']);
     return $project;
 }
コード例 #2
0
 public function resumeExecution($projectId, $configId)
 {
     $this->beginTran();
     $configRepo = ConfigurationRepository::getInstance();
     $activeUsers = ProjectsRepository::getInstance()->getProjectAssignedUsers($projectId, $configId);
     $configRepo->closeActiveConfiguration($configId);
     $newConfig = $configRepo->createNewConfiguration($projectId);
     SetupRepository::getInstance()->assignUsersToProject($projectId, $activeUsers, $newConfig['configId']);
     $this->commit();
 }
コード例 #3
0
 public function allocateTestCases($projectId, $algorithm, $newConfigId, $date, $configExists)
 {
     $users = ProjectsRepository::getInstance()->getProjectAssignedUsers($projectId, $newConfigId);
     $assignedDays = DaysRepository::getInstance()->getProjectAssignedDays($projectId);
     $remainingDays = DaysRepository::getInstance()->getProjectRemainingDays($projectId);
     if (count($remainingDays) == 0) {
         $this->rollback();
         throw new ApplicationException('Allocation of test cases not possible due no days planned!', 400);
     }
     $lastConfigResetDate = DaysRepository::getInstance()->getLastConfigReset($projectId);
     $unallocated = TestCasesRepository::getInstance()->getProjectUnallocatedTestCases($projectId);
     $expired = TestCasesRepository::getInstance()->getProjectExpiredNonFinalTestCases($projectId);
     $testCasesToAllocate = array_merge($unallocated, $expired);
     $actualTCPD = count($testCasesToAllocate) / count($remainingDays);
     $expectedTCPD = $this->calcExpectedTCPD($users);
     $ratio = $actualTCPD / $expectedTCPD;
     if ($actualTCPD < $expectedTCPD && $algorithm == 1) {
         $ratio = 1;
     }
     $allocatedCount = 0;
     foreach ($assignedDays as $day => $dayValue) {
         // Make sure to transfer test cases only to the current or next days
         $expiredDay = new \DateTime($dayValue['dayDate']) < new \DateTime($date);
         if ($expiredDay || $dayValue['dayDate'] == $lastConfigResetDate) {
             continue;
         }
         $tolerance = 0;
         if ($configExists) {
             $tolerance = round($dayValue['expected'] * AppConfig::PERCENTAGE_TOLERANCE_TEST_CASES_PER_DAY / 100);
         }
         foreach ($users as $userK => $userV) {
             $userTestCasesCount = round($userV['performanceIndicator'] * $ratio);
             for ($i = 0; $i < $userTestCasesCount; $i++) {
                 // Check if all testCases are allocated
                 $noMoreTestCases = $allocatedCount == count($testCasesToAllocate);
                 $isDayFull = false;
                 if ($ratio == 1 && $configExists) {
                     $isDayFull = $dayValue['allocated'] >= $dayValue['expected'] + $tolerance;
                 }
                 if ($noMoreTestCases || $isDayFull) {
                     break;
                 }
                 // Keep the user of the test case if it exists else set the current user's
                 $userId = $userV['userId'];
                 if (isset($testCasesToAllocate[$allocatedCount]['userId'])) {
                     $userId = $testCasesToAllocate[$allocatedCount]['userId'];
                 }
                 // Keep the status of the testCase if it exists else default
                 $statusId = 1;
                 if (isset($testCasesToAllocate[$allocatedCount]['statusId'])) {
                     $statusId = $testCasesToAllocate[$allocatedCount]['statusId'];
                 }
                 TestCasesRepository::getInstance()->allocateTestCase($testCasesToAllocate[$allocatedCount]['testCaseId'], $userId, $dayValue['dayId'], $statusId);
                 $dayValue['allocated']++;
                 $allocatedCount++;
             }
         }
     }
     if ($configExists && $allocatedCount < count($testCasesToAllocate)) {
         $this->rollback();
         throw new ApplicationException('Automatic allocation of test cases not possible due to insufficient quota!', 400);
     }
 }
コード例 #4
0
 /**
  * @method GET
  * @customRoute('projects/int/sync')
  */
 public function syncProjectTestCases($projectId)
 {
     $result = ProjectsRepository::getInstance()->syncProjectTestCases($projectId);
     return $result;
 }
コード例 #5
0
 /**
  * @authorize
  * @method GET
  * @customRoute('projects/int/testCases');
  */
 public function getProjectTestCases($projectId)
 {
     ProjectsRepository::getInstance()->syncProjectTestCases($projectId);
     $testCases = ProjectsRepository::getInstance()->getProjectTestCasesForAllocationMap($projectId);
     return $testCases;
 }
コード例 #6
0
 /**
  * @authorize
  * @method PUT
  * @customRoute('projects/int/extendDuration')
  */
 public function extendProjectDuration($projectId, ExtendDurationBindingModel $model)
 {
     $config = ConfigurationRepository::getInstance()->getActiveProjectConfiguration($projectId);
     $activeUsers = ProjectsRepository::getInstance()->getProjectAssignedUsers($projectId, $config['configId']);
     $expectedTCPD = SetupRepository::getInstance()->calcExpectedTCPD($activeUsers);
     DaysRepository::getInstance()->extendProjectDuration($projectId, $model, $expectedTCPD, $config);
     return ['msg' => "Project with Id {$projectId} extended successfully!"];
 }