Example #1
0
 /**
  * @param GearmanJob|null $job
  * @return mixed
  */
 public function execute(GearmanJob $job = null)
 {
     $data = $this->getWorkload($job)->getParams()['data'];
     // Создаем нужный элемент профилирования
     $listProfiler = ListProfiler::findOne(['message' => $data->message, 'project_id' => $data->project_id]);
     if (!$listProfiler) {
         $listProfiler = new ListProfiler();
         $listProfiler->message = $data->message;
         $listProfiler->project_id = $data->project_id;
     }
     if (!$listProfiler->save()) {
         $job->sendStatus(400, 400);
         return false;
     }
     $model = new Profiler();
     $model->date_create = \Yii::$app->formatter->asDate($data->date_create, 'yyyy-MM-dd H:m:s');
     $model->project_id = $data->project_id;
     $model->type = $data->type;
     $model->message_id = $listProfiler->id;
     $model->duration = $data->duration;
     $model->time_start = $data->time_start;
     $model->time_end = $data->time_end;
     if (!$model->save()) {
         $job->sendStatus(400, 400);
         return false;
     }
     $job->sendStatus(200, 200);
     return true;
 }
Example #2
0
 /**
  * @author Dianov German <*****@*****.**>
  * Find profile list by ID
  * @param $id profiler id
  */
 protected function findProfiler($id)
 {
     if (($model = ListProfiler::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('Профайлер не найден');
     }
 }
Example #3
0
 /**
  * @param GearmanJob|null $job
  * @return mixed
  */
 public function execute(GearmanJob $job = null)
 {
     $data = $data = $this->getWorkload($job)->getParams()['data'];
     $id = $data['id'];
     $staff = $data['staff_id'];
     if (!is_int($id) or !is_int($staff)) {
         $job->sendStatus(400, 400);
         return false;
     }
     // Удаление из кеша даты последнего просмотра пользователем профайлеров проекта
     $profiler = ListProfiler::findAll(['project_id' => $id]);
     $profilerId = ArrayHelper::getColumn($profiler, 'id');
     LastActiveDate::getModel(LastActiveDate::TYPE_PROFILER)->setData($profilerId)->setUserId($staff)->delete();
     // Удаление списка профайлеров проекта
     ListProfiler::deleteAll(['project_id' => $id]);
     // Удаление данных проекта
     Profiler::deleteAll(['project_id' => $id]);
     // Удаление из кеша списка профайлеров проекта
     $command = new DeleteProfilerList();
     $command->setData($id)->execute();
     $job->sendStatus(200, 200);
     return true;
 }
Example #4
0
 protected function findModelListProfile($id)
 {
     if (($model = ListProfiler::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('List Profile not found');
     }
 }