From 86204e877e41c7aba7885002a63be3ad207a8e38 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Wed, 27 Nov 2024 19:04:24 -0800 Subject: [PATCH] use transaction check for PatchSubmissionModel --- pkg/service/submissions.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/service/submissions.go b/pkg/service/submissions.go index 20f8f68..022c813 100644 --- a/pkg/service/submissions.go +++ b/pkg/service/submissions.go @@ -128,13 +128,12 @@ func (svc *Service) PatchSubmissionCompleted(ctx context.Context, params api.Pat func (svc *Service) PatchSubmissionModel(ctx context.Context, params api.PatchSubmissionModelParams) error { // check if caller has Submitter role // check if Status is ChangesRequested|Submitted|UnderConstruction - // PROBLEM how to deal with async? data may become out of date pmap := datastore.Optional() pmap.AddNotNil("asset_id", params.ModelID) pmap.AddNotNil("asset_version", params.VersionID) //always reset completed when model changes pmap.Add("completed",false) - err := svc.DB.Submissions().Update(ctx, params.SubmissionID, pmap) + err := svc.DB.Submissions().IfStatusThenUpdate(ctx, params.SubmissionID, []model.Status{model.StatusChangesRequested,model.StatusSubmitted,model.StatusUnderConstruction}, pmap) return err }