From ef41e367e0ca7c31d34e5dae362d3529b2275bb4 Mon Sep 17 00:00:00 2001 From: Peter Nemere Date: Fri, 14 Jun 2024 16:20:52 +1000 Subject: [PATCH] Ensuring JobStatus structs have all fields filled out even if stored as part of quant item. Also ensuring start time is set, there were some ways in past where it ended up 0 --- api/quantification/create.go | 17 +++++++++++------ api/quantification/importCSV.go | 16 ++++++++++------ api/ws/handlers/quantification-retrieval.go | 6 ++++++ 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/api/quantification/create.go b/api/quantification/create.go index 5f163ea1..8e06226b 100644 --- a/api/quantification/create.go +++ b/api/quantification/create.go @@ -378,12 +378,17 @@ func (r *quantNodeRunner) triggerPiquantNodes(wg *sync.WaitGroup) { Params: r.quantStartSettings, Elements: elements, Status: &protos.JobStatus{ - JobId: r.jobId, - Status: protos.JobStatus_COMPLETE, - Message: completeMsg, - EndUnixTimeSec: uint32(now), - OutputFilePath: quantOutPath, - OtherLogFiles: piquantLogList, + JobId: r.jobId, + JobItemId: r.jobId, + Status: protos.JobStatus_COMPLETE, + Message: completeMsg, + StartUnixTimeSec: r.quantStartSettings.StartUnixTimeSec, + EndUnixTimeSec: uint32(now), + OutputFilePath: quantOutPath, + OtherLogFiles: piquantLogList, + Name: r.quantStartSettings.UserParams.Name, + Elements: r.quantStartSettings.UserParams.Elements, + RequestorUserId: r.quantStartSettings.RequestorUserId, }, } diff --git a/api/quantification/importCSV.go b/api/quantification/importCSV.go index c9278741..68c410c1 100644 --- a/api/quantification/importCSV.go +++ b/api/quantification/importCSV.go @@ -97,12 +97,16 @@ func ImportQuantCSV( }, Elements: elements, Status: &protos.JobStatus{ - JobId: quantId, - Status: protos.JobStatus_COMPLETE, - Message: csvOrigin + " quantification processed", - OtherLogFiles: []string{}, - EndUnixTimeSec: uint32(ownerItem.CreatedUnixSec), - OutputFilePath: quantOutPath, + JobId: quantId, + JobItemId: quantId, + Status: protos.JobStatus_COMPLETE, + Message: csvOrigin + " quantification processed", + OtherLogFiles: []string{}, + EndUnixTimeSec: uint32(ownerItem.CreatedUnixSec), + OutputFilePath: quantOutPath, + StartUnixTimeSec: uint32(ownerItem.CreatedUnixSec), + Name: quantName, + Elements: elements, }, } diff --git a/api/ws/handlers/quantification-retrieval.go b/api/ws/handlers/quantification-retrieval.go index 5af6fb39..a3376fc2 100644 --- a/api/ws/handlers/quantification-retrieval.go +++ b/api/ws/handlers/quantification-retrieval.go @@ -49,6 +49,12 @@ func HandleQuantGetReq(req *protos.QuantGetReq, hctx wsHelpers.HandlerContext) ( } } + // We seem to have some old quants where the status struct says start time was 0, but there is another start time in quant params, so + // substitute a non-zero value in this case + if dbItem.Status.StartUnixTimeSec == 0 && dbItem.Params.StartUnixTimeSec > 0 { + dbItem.Status.StartUnixTimeSec = dbItem.Params.StartUnixTimeSec + } + dbItem.Owner = wsHelpers.MakeOwnerSummary(ownerItem, hctx.SessUser, hctx.Svcs.MongoDB, hctx.Svcs.TimeStamper) return &protos.QuantGetResp{