Commit e4f59292 authored by 375242562@qq.com's avatar 375242562@qq.com

fix: 批量匹配日志开始/结束时间相同问题

- "开始时间"改用 created_at(HTTP 请求触发时即记录,早于后台任务)
  避免 0 配对任务中 started_at 与 completed_at 在同一秒内赋值显示相同
- 新增"耗时"列:自动计算 created_at → completed_at 差值并格式化
  (< 1 秒 / X 秒 / X 分 Y 秒),直观反映任务运行时长
Co-Authored-By: default avatarClaude Sonnet 4.6 <noreply@anthropic.com>
parent 00673e17
......@@ -29,6 +29,15 @@ import type { MatchingResult } from '../types/matching'
const PAGE_SIZE = 10
function formatDuration(start?: string, end?: string): string {
if (!start || !end) return ''
const ms = new Date(end).getTime() - new Date(start).getTime()
if (ms < 0) return ''
if (ms < 1000) return '< 1 秒'
if (ms < 60000) return `${Math.round(ms / 1000)} 秒`
return `${Math.floor(ms / 60000)}${Math.round((ms % 60000) / 1000)} 秒`
}
const JOB_STATUS_MAP: Record<string, { label: string; color: 'default' | 'info' | 'warning' | 'success' | 'error' }> = {
pending: { label: '待启动', color: 'default' },
running: { label: '运行中', color: 'info' },
......@@ -310,8 +319,9 @@ export function MatchingPage() {
<TableCell>状态</TableCell>
<TableCell>进度</TableCell>
<TableCell>触发人</TableCell>
<TableCell>开始时间</TableCell>
<TableCell>结束时间</TableCell>
<TableCell>触发时间</TableCell>
<TableCell>完成时间</TableCell>
<TableCell>耗时</TableCell>
</TableRow>
</TableHead>
<TableBody>
......@@ -364,7 +374,7 @@ export function MatchingPage() {
</TableCell>
<TableCell>
<Typography variant="caption" color="text.secondary">
{job.started_at ? new Date(job.started_at).toLocaleString('zh-CN') : ''}
{new Date(job.created_at).toLocaleString('zh-CN')}
</Typography>
</TableCell>
<TableCell>
......@@ -372,10 +382,15 @@ export function MatchingPage() {
{job.completed_at ? new Date(job.completed_at).toLocaleString('zh-CN') : ''}
</Typography>
</TableCell>
<TableCell>
<Typography variant="caption" color="text.secondary">
{formatDuration(job.created_at, job.completed_at)}
</Typography>
</TableCell>
</TableRow>
{hasError && (
<TableRow key={`${job.id}-err`}>
<TableCell colSpan={7} sx={{ py: 0 }}>
<TableCell colSpan={8} sx={{ py: 0 }}>
<Collapse in={isExpanded}>
<Box sx={{ p: 1.5, bgcolor: 'grey.50', borderRadius: 1, my: 0.5 }}>
<Typography
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment