/
v.bolshakov
/
AIEcosystem-Testing
Обзор
Документация
Войти
/
v.bolshakov
/
AIEcosystem-Testing
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
dev
common/forms/user/XBenchAnalysisTaskForm.php
91 строка
2 KB
Developer
Initial commit
03 авг 2026, 17:43
03 авг 2026, 17:43
7433917
Код
Авторство
О чём код?
<?php namespace common\forms\user; use common\forms\task\BaseTaskForm; use common\helpers\ArrayHelper; use common\models\Task; use frontend\forms\ai\ReportAssistantForm; use Yii; use yii\helpers\Json; /** * Форма запроса к XBenchAnalysis * * @author Dmitry E. Semenov <sde.tomsk@gmail.com> * @copyright Self (c) 2024 */ class XBenchAnalysisTaskForm extends BaseTaskForm { /** * Входной массив данных * @var array */ public $input_result = []; /** * @inheritdoc */ protected $request_class = ReportAssistantForm::class; /** * @inheritdoc */ public function beforeValidate() { $parent = parent::beforeValidate(); // TODO: Change the autogenerated stub if ($parent) { $this->task_id = Task::find() ->andWhere([ 'guid' => Task::XBench_Analysis ]) ->scalar(); foreach ($this->text as &$text) { $text = Json::encode($text); } } return $parent; } /** * @inheritdoc */ protected function afterSave($result) { parent::afterSave($result); // TODO: Change the autogenerated stub if ($result) { $response = (array)$this->model; $response_list = ArrayHelper::remove($response, 'items'); $table = []; foreach ((array)$response_list as $the_response) { $the_response = str_replace(['```json', '```'], ['', ''], $the_response); $the_response = Json::decode($the_response); $entries = ArrayHelper::getValue($the_response, 'Entries', []); foreach ((array)$entries as $row) { $Line_id = ArrayHelper::getValue($row, 'Line_id'); if ($Line_id) { $input = ArrayHelper::getValue($this->input_result, $Line_id); if ($input) { $table[] = [ ArrayHelper::getValue($input, 0, ''), ArrayHelper::getValue($input, 3, ''), ArrayHelper::getValue($row, 'Flag', ''), ArrayHelper::getValue($row, 'Commentary', '') ]; } } } } $this->model['table'] = $table; } } }