Unverified Commit d1ad9c89 authored by gaoyan's avatar gaoyan Committed by GitHub

[Fix-#2756] Fix the Devops job list duration formate error (#2802)

* fix log error * Fix the Devops job list duration formate error
parent bfbac4bc
...@@ -25,7 +25,7 @@ import { l } from '@/utils/intl'; ...@@ -25,7 +25,7 @@ import { l } from '@/utils/intl';
import { ProCard } from '@ant-design/pro-components'; import { ProCard } from '@ant-design/pro-components';
import { Button, Empty, Result } from 'antd'; import { Button, Empty, Result } from 'antd';
import { useState } from 'react'; import { useState } from 'react';
import { isStatusDone } from '../../function'; import { isNotFinallyStatus } from '../../function';
const JobConfigTab = (props: JobProps) => { const JobConfigTab = (props: JobProps) => {
const { jobDetail } = props; const { jobDetail } = props;
...@@ -34,7 +34,7 @@ const JobConfigTab = (props: JobProps) => { ...@@ -34,7 +34,7 @@ const JobConfigTab = (props: JobProps) => {
return ( return (
<> <>
{isStatusDone(jobDetail?.instance?.status as string) && !showHistory ? ( {isNotFinallyStatus(jobDetail?.instance?.status as string) && !showHistory ? (
<Result <Result
status='warning' status='warning'
title={l('devops.jobinfo.unable.obtain.status')} title={l('devops.jobinfo.unable.obtain.status')}
...@@ -51,7 +51,7 @@ const JobConfigTab = (props: JobProps) => { ...@@ -51,7 +51,7 @@ const JobConfigTab = (props: JobProps) => {
} }
/> />
) : undefined} ) : undefined}
{showHistory || !isStatusDone(jobDetail?.instance?.status as string) ? ( {showHistory || !isNotFinallyStatus(jobDetail?.instance?.status as string) ? (
<> <>
<JobDesc jobDetail={jobDetail} /> <JobDesc jobDetail={jobDetail} />
<ProCard <ProCard
......
...@@ -18,10 +18,10 @@ ...@@ -18,10 +18,10 @@
*/ */
import StatusTag from '@/components/JobTags/StatusTag'; import StatusTag from '@/components/JobTags/StatusTag';
import { getJobDuration } from '@/pages/DevOps/function';
import { queryList } from '@/services/api'; import { queryList } from '@/services/api';
import { API_CONSTANTS } from '@/services/endpoints'; import { API_CONSTANTS } from '@/services/endpoints';
import { Jobs } from '@/types/DevOps/data'; import { Jobs } from '@/types/DevOps/data';
import { parseSecondStr } from '@/utils/function';
import { l } from '@/utils/intl'; import { l } from '@/utils/intl';
import type { ActionType, ProColumns } from '@ant-design/pro-components'; import type { ActionType, ProColumns } from '@ant-design/pro-components';
import { ProTable } from '@ant-design/pro-components'; import { ProTable } from '@ant-design/pro-components';
...@@ -62,7 +62,7 @@ const JobHistoryList = (props: HistoryProps) => { ...@@ -62,7 +62,7 @@ const JobHistoryList = (props: HistoryProps) => {
}, },
{ {
title: l('global.table.useTime'), title: l('global.table.useTime'),
render: (_: any, row: { duration: number }) => parseSecondStr(row.duration) render: (_: any, row: Jobs.JobInstance) => getJobDuration(row)
}, },
{ {
title: l('global.table.operate'), title: l('global.table.operate'),
......
...@@ -21,12 +21,12 @@ import JobLifeCycleTag from '@/components/JobTags/JobLifeCycleTag'; ...@@ -21,12 +21,12 @@ import JobLifeCycleTag from '@/components/JobTags/JobLifeCycleTag';
import StatusTag from '@/components/JobTags/StatusTag'; import StatusTag from '@/components/JobTags/StatusTag';
import { DevopContext } from '@/pages/DevOps'; import { DevopContext } from '@/pages/DevOps';
import { JOB_LIFE_CYCLE } from '@/pages/DevOps/constants'; import { JOB_LIFE_CYCLE } from '@/pages/DevOps/constants';
import { getJobDuration } from '@/pages/DevOps/function';
import JobHistoryList from '@/pages/DevOps/JobList/components/JobHistoryList/JobHistoryList'; import JobHistoryList from '@/pages/DevOps/JobList/components/JobHistoryList/JobHistoryList';
import { queryList } from '@/services/api'; import { queryList } from '@/services/api';
import { PROTABLE_OPTIONS_PUBLIC } from '@/services/constants'; import { PROTABLE_OPTIONS_PUBLIC } from '@/services/constants';
import { API_CONSTANTS } from '@/services/endpoints'; import { API_CONSTANTS } from '@/services/endpoints';
import { Jobs } from '@/types/DevOps/data'; import { Jobs } from '@/types/DevOps/data';
import { parseMilliSecondStr } from '@/utils/function';
import { l } from '@/utils/intl'; import { l } from '@/utils/intl';
import { ClockCircleTwoTone, EyeTwoTone, RedoOutlined } from '@ant-design/icons'; import { ClockCircleTwoTone, EyeTwoTone, RedoOutlined } from '@ant-design/icons';
import type { ActionType, ProColumns } from '@ant-design/pro-components'; import type { ActionType, ProColumns } from '@ant-design/pro-components';
...@@ -77,7 +77,7 @@ const JobList = () => { ...@@ -77,7 +77,7 @@ const JobList = () => {
{ {
title: l('global.table.useTime'), title: l('global.table.useTime'),
hideInSearch: true, hideInSearch: true,
render: (_: any, row: Jobs.JobInstance) => parseMilliSecondStr(row.duration) render: (_: any, row: Jobs.JobInstance) => getJobDuration(row)
}, },
{ {
title: l('global.table.status'), title: l('global.table.status'),
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
*/ */
import { JOB_STATUS } from '@/pages/DevOps/constants'; import { JOB_STATUS } from '@/pages/DevOps/constants';
import { Jobs } from '@/types/DevOps/data';
import { parseMilliSecondStr } from '@/utils/function';
/** /**
* Checks if a job status indicates that the job is done. * Checks if a job status indicates that the job is done.
...@@ -39,3 +41,25 @@ export function isStatusDone(type: string) { ...@@ -39,3 +41,25 @@ export function isStatusDone(type: string) {
return false; return false;
} }
} }
export function isNotFinallyStatus(type: string) {
if (!type) {
return true;
}
switch (type) {
case JOB_STATUS.RECONNECTING:
case JOB_STATUS.UNKNOWN:
return true;
default:
return false;
}
}
export function getJobDuration(jobInstance: Jobs.JobInstance) {
if (isStatusDone(jobInstance.status)) {
return parseMilliSecondStr(jobInstance.duration);
} else {
const currentTimestamp = Date.now();
const duration = currentTimestamp - new Date(jobInstance.createTime).getTime();
return parseMilliSecondStr(duration);
}
}
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