Ejemplo n.º 1
0
 public function getNumRunRequests()
 {
     $num = 0;
     $assessmentRunRequests = AssessmentRunRequest::where('assessment_run_id', '=', $this->assessment_run_id)->get();
     foreach ($assessmentRunRequests as $assessmentRunRequest) {
         $runRequest = RunRequest::where('run_request_id', '=', $assessmentRunRequest->run_request_id)->first();
         // don't report one time requests
         //
         if ($runRequest->name != 'One-time') {
             $num++;
         }
     }
     return $num;
 }
 public function deleteIndex($runRequestUuid)
 {
     $runRequest = RunRequest::where('run_request_uuid', '=', $runRequestUuid)->first();
     $runRequest->delete();
     return $runRequest;
 }
 public function getScheduledByProject($projectUuid)
 {
     $assessmentRuns = $this->getAllByProject($projectUuid);
     // get one time run request
     //
     $oneTimeRunRequest = RunRequest::where('name', '=', 'One-time')->first();
     // compile list of non-one time assessment run requests
     //
     $assessmentRunRequests = new Collection();
     if ($oneTimeRunRequest) {
         foreach ($assessmentRuns as $assessmentRun) {
             $assessmentRunRequests = $assessmentRunRequests->merge(AssessmentRunRequest::where('assessment_run_id', '=', $assessmentRun->assessment_run_id)->where('run_request_id', '!=', $oneTimeRunRequest->run_request_id)->get());
         }
     } else {
         foreach ($assessmentRuns as $assessmentRun) {
             $assessmentRunRequests = $assessmentRunRequests->merge(AssessmentRunRequest::where('assessment_run_id', '=', $assessmentRun->assessment_run_id)->get());
         }
     }
     // get limit filter
     //
     $limit = Input::get('limit');
     // create scheduled assessment runs containing the run request
     //
     $scheduledAssessmentRuns = new Collection();
     foreach ($assessmentRunRequests as $assessmentRunRequest) {
         $scheduledAssessmentRun = AssessmentRun::where('assessment_run_id', '=', $assessmentRunRequest->assessment_run_id)->first()->toArray();
         $runRequest = RunRequest::where('run_request_id', '=', $assessmentRunRequest->run_request_id)->first();
         // return run requests up to limit
         //
         if (!$limit || sizeof($scheduledAssessmentRuns) < $limit) {
             $scheduledAssessmentRun['run_request'] = $runRequest->toArray();
             $scheduledAssessmentRuns->push($scheduledAssessmentRun);
         } else {
             break;
         }
     }
     return $scheduledAssessmentRuns;
 }