Skip to content

Commit

Permalink
Add support for reporting custom duration on PipelineRuns
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanGreene authored and tekton-robot committed May 16, 2022
1 parent 00f4264 commit a5190bd
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions packages/components/src/components/PipelineRuns/PipelineRuns.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ const PipelineRuns = ({
pipelineRun.metadata.creationTimestamp,
getPipelineRunDisplayName = ({ pipelineRunMetadata }) =>
pipelineRunMetadata.name,
getPipelineRunDuration = pipelineRun => {
const creationTimestamp = getPipelineRunCreatedTime(pipelineRun);
const { lastTransitionTime, status } = getStatus(pipelineRun);

let endTime = Date.now();
if (status === 'False' || status === 'True') {
endTime = new Date(lastTransitionTime).getTime();
}

return endTime - new Date(creationTimestamp).getTime();
},
getPipelineRunId = pipelineRun => pipelineRun.metadata.uid,
getPipelineRunsByPipelineURL = urls.pipelineRuns.byPipeline,
getPipelineRunStatus = (pipelineRun, intl) => {
Expand Down Expand Up @@ -149,7 +160,7 @@ const PipelineRuns = ({
});
const pipelineRefName =
pipelineRun.spec.pipelineRef && pipelineRun.spec.pipelineRef.name;
const { lastTransitionTime, reason, status } = getStatus(pipelineRun);
const { reason, status } = getStatus(pipelineRun);
const statusIcon = getPipelineRunStatusIcon(pipelineRun);
const pipelineRunURL = getPipelineRunURL({
namespace,
Expand All @@ -163,15 +174,8 @@ const PipelineRuns = ({
pipelineName: pipelineRefName
});

let endTime = Date.now();
if (status === 'False' || status === 'True') {
endTime = new Date(lastTransitionTime).getTime();
}

const duration = (
<FormattedDuration
milliseconds={endTime - new Date(creationTimestamp).getTime()}
/>
<FormattedDuration milliseconds={getPipelineRunDuration(pipelineRun)} />
);

const pipelineRunActions = getRunActions(pipelineRun);
Expand Down

0 comments on commit a5190bd

Please sign in to comment.