更新
This commit is contained in:
@@ -15,6 +15,7 @@ class KbConfigLists extends BaseAdminDataLists
|
||||
->whereOrLike('name', 'qwen_%')
|
||||
->whereOrLike('name', 'openai_%')
|
||||
->whereOrLike('name', 'mtranserver_%')
|
||||
->whereOrLike('name', 'whisper_asr_%')
|
||||
->whereOrLike('name', 'assistant_%')
|
||||
->whereOr('name', '=', 'post_analysis_prompt');
|
||||
})->limit($this->limitOffset, $this->limitLength)
|
||||
@@ -31,6 +32,7 @@ class KbConfigLists extends BaseAdminDataLists
|
||||
->whereOrLike('name', 'qwen_%')
|
||||
->whereOrLike('name', 'openai_%')
|
||||
->whereOrLike('name', 'mtranserver_%')
|
||||
->whereOrLike('name', 'whisper_asr_%')
|
||||
->whereOrLike('name', 'assistant_%')
|
||||
->whereOr('name', '=', 'post_analysis_prompt');
|
||||
})->count();
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\lists\crawler;
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\CrawlerTaskLog;
|
||||
|
||||
class TaskLogLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['action', 'status', 'trigger_type', 'source'],
|
||||
'%like%' => ['task_name', 'task_key'],
|
||||
'between_time' => 'create_time',
|
||||
];
|
||||
}
|
||||
|
||||
public function lists(): array
|
||||
{
|
||||
$lists = CrawlerTaskLog::field('id,task_key,task_name,action,cron_expression,source,container_id,status,trigger_type,output,error_message,elapsed,started_at,finished_at,create_time,update_time')
|
||||
->where($this->searchWhere)
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order('id', 'desc')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
foreach ($lists as &$item) {
|
||||
$item = self::formatItem($item);
|
||||
}
|
||||
|
||||
return $lists;
|
||||
}
|
||||
|
||||
public function count(): int
|
||||
{
|
||||
return CrawlerTaskLog::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
public static function formatItem(array $item): array
|
||||
{
|
||||
$item['status_text'] = match ((int) ($item['status'] ?? 0)) {
|
||||
0 => '执行中',
|
||||
1 => '成功',
|
||||
2 => '失败',
|
||||
3 => '已跳过',
|
||||
default => '未知',
|
||||
};
|
||||
$item['trigger_type_text'] = ((int) ($item['trigger_type'] ?? 1)) === 2 ? '手动' : '自动';
|
||||
foreach (['started_at', 'finished_at', 'create_time', 'update_time'] as $field) {
|
||||
$value = $item[$field] ?? 0;
|
||||
$item[$field . '_text'] = self::formatTime($value);
|
||||
}
|
||||
$item['output_preview'] = mb_substr((string) ($item['output'] ?? ''), 0, 120);
|
||||
return $item;
|
||||
}
|
||||
|
||||
private static function formatTime($value): string
|
||||
{
|
||||
if (empty($value)) {
|
||||
return '-';
|
||||
}
|
||||
return is_numeric($value) ? date('Y-m-d H:i:s', (int) $value) : (string) $value;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user