From 10079ca510e86f90ef7eaf473a7310f495cf272e Mon Sep 17 00:00:00 2001 From: Morgan Taylor Date: Thu, 21 Nov 2024 16:03:37 -0500 Subject: [PATCH] add timestamps to pipeline run result --- common/openapi.yml | 6 +++++- .../app/controller/PipelineRunsApiController.java | 7 ++++++- .../common/utils/CommonPipelineRunStatusEnum.java | 4 ++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/common/openapi.yml b/common/openapi.yml index 985473ea..e99d084b 100644 --- a/common/openapi.yml +++ b/common/openapi.yml @@ -733,7 +733,7 @@ components: description: | Object containing the job id, status, and user-provided description of a Pipeline Run. type: object - required: [ jobId, status ] + required: [ jobId, status, timeSubmitted ] properties: jobId: $ref: '#/components/schemas/Id' @@ -741,6 +741,10 @@ components: $ref: "#/components/schemas/PipelineRunStatus" description: $ref: "#/components/schemas/PipelineRunDescription" + timeSubmitted: + $ref: "#/components/schemas/JobTimeSubmitted" + timeCompleted: + $ref: "#/components/schemas/JobTimeCompleted" PipelineRunDescription: description: | diff --git a/service/src/main/java/bio/terra/pipelines/app/controller/PipelineRunsApiController.java b/service/src/main/java/bio/terra/pipelines/app/controller/PipelineRunsApiController.java index 1094c119..8e15963b 100644 --- a/service/src/main/java/bio/terra/pipelines/app/controller/PipelineRunsApiController.java +++ b/service/src/main/java/bio/terra/pipelines/app/controller/PipelineRunsApiController.java @@ -198,7 +198,12 @@ public ResponseEntity getAllPipelineRuns( new ApiPipelineRun() .jobId(pipelineRun.getJobId()) .status(pipelineRun.getStatus().name()) - .description(pipelineRun.getDescription())) + .description(pipelineRun.getDescription()) + .timeSubmitted(pipelineRun.getCreated().toString()) + .timeCompleted( + pipelineRun.getStatus().isCompleted() + ? pipelineRun.getUpdated().toString() + : null)) .toList(); ApiGetPipelineRunsResponse apiGetPipelineRunsResponse = diff --git a/service/src/main/java/bio/terra/pipelines/common/utils/CommonPipelineRunStatusEnum.java b/service/src/main/java/bio/terra/pipelines/common/utils/CommonPipelineRunStatusEnum.java index 045cdb34..8f6951aa 100644 --- a/service/src/main/java/bio/terra/pipelines/common/utils/CommonPipelineRunStatusEnum.java +++ b/service/src/main/java/bio/terra/pipelines/common/utils/CommonPipelineRunStatusEnum.java @@ -10,4 +10,8 @@ public enum CommonPipelineRunStatusEnum { public boolean isSuccess() { return this == SUCCEEDED; } + + public boolean isCompleted() { + return this == SUCCEEDED || this == FAILED; + } }