|
32 | 32 | use DBA\Job; |
33 | 33 | use DBA\ProjectUser; |
34 | 34 | use DBA\QueryFilter; |
| 35 | +use DBA\Event; |
35 | 36 |
|
36 | 37 | class Evaluation_Controller extends Controller { |
37 | 38 |
|
@@ -111,12 +112,30 @@ public function detail() { |
111 | 112 | $qF1 = new ContainFilter(Job::STATUS, [Define::JOB_STATUS_FAILED, Define::JOB_STATUS_ABORTED]); |
112 | 113 | $qF2 = new QueryFilter(Job::EVALUATION_ID, $evaluation->getId(), "="); |
113 | 114 | $uS = new UpdateSet(Job::STATUS, Define::JOB_STATUS_SCHEDULED); |
| 115 | + $jobs = Factory::getJobFactory()->filter([Factory::FILTER => [$qF1, $qF2]]); // For events, we need the old status |
114 | 116 | Factory::getJobFactory()->massUpdate([Factory::FILTER => [$qF1, $qF2], Factory::UPDATE => $uS]); |
| 117 | + // Add events |
| 118 | + $auth = Auth_Library::getInstance(); |
| 119 | + foreach ($jobs as $job) { |
| 120 | + $event = new Event(0, "Job has been rescheduled", date('Y-m-d H:i:s'), |
| 121 | + "Job of evaluation '" . $evaluation->getName() . "' running in environment '" . $job->getEnvironment() . "' has been rescheduled. Previous status has been: " . Util::getStatusText($job->getStatus()), |
| 122 | + Define::EVENT_JOB, $job->getId(), ($auth->isLoggedIn()) ? $auth->getUserID() : null, null); |
| 123 | + Factory::getEventFactory()->save($event); |
| 124 | + } |
115 | 125 | } else if (!empty($this->post['abort']) && $this->post['abort'] == 'all') { |
116 | 126 | $qF1 = new ContainFilter(Job::STATUS, [Define::JOB_STATUS_SCHEDULED, Define::JOB_STATUS_SETUP, Define::JOB_STATUS_RUNNING, Define::JOB_STATUS_FAILED]); |
117 | 127 | $qF2 = new QueryFilter(Job::EVALUATION_ID, $evaluation->getId(), "="); |
118 | 128 | $uS = new UpdateSet(Job::STATUS, Define::JOB_STATUS_ABORTED); |
| 129 | + $jobs = Factory::getJobFactory()->filter([Factory::FILTER => [$qF1, $qF2]]); // For events, we need the old status |
119 | 130 | Factory::getJobFactory()->massUpdate([Factory::FILTER => [$qF1, $qF2], Factory::UPDATE => $uS]); |
| 131 | + // Add events |
| 132 | + $auth = Auth_Library::getInstance(); |
| 133 | + foreach ($jobs as $job) { |
| 134 | + $event = new Event(0, "Job has been aborted", date('Y-m-d H:i:s'), |
| 135 | + "Job of evaluation '" . $evaluation->getName() . "' running in environment '" . $job->getEnvironment() . "' has been aborted. Previous status has been: " . Util::getStatusText($job->getStatus()), |
| 136 | + Define::EVENT_JOB, $job->getId(), ($auth->isLoggedIn()) ? $auth->getUserID() : null, null); |
| 137 | + Factory::getEventFactory()->save($event); |
| 138 | + } |
120 | 139 | } else if (!empty($this->post['star'])) { |
121 | 140 | if ($evaluation->getIsStarred()) { |
122 | 141 | throw new ProcessException("Evaluation is already starred!"); |
|
0 commit comments