From efd24023bcb7059d93c9958fc41b9d3e0fe7a9b6 Mon Sep 17 00:00:00 2001 From: Sonja Happ Date: Tue, 23 Feb 2021 11:39:04 +0100 Subject: [PATCH] Fix a but in add results endpoint, add model and result as optional action params --- routes/infrastructure-component/ic_amqpclient.go | 2 ++ routes/result/result_validators.go | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/routes/infrastructure-component/ic_amqpclient.go b/routes/infrastructure-component/ic_amqpclient.go index 99e4497..f9ca3fc 100644 --- a/routes/infrastructure-component/ic_amqpclient.go +++ b/routes/infrastructure-component/ic_amqpclient.go @@ -46,6 +46,8 @@ type Action struct { Act string `json:"action"` When int64 `json:"when"` Parameters json.RawMessage `json:"parameters,omitempty"` + Model json.RawMessage `json:"model,omitempty"` + Results json.RawMessage `json:"results,omitempty"` } type ICStatus struct { diff --git a/routes/result/result_validators.go b/routes/result/result_validators.go index c94938f..e93054e 100644 --- a/routes/result/result_validators.go +++ b/routes/result/result_validators.go @@ -69,7 +69,12 @@ func (r *addResultRequest) createResult() Result { s.Description = r.Result.Description s.ConfigSnapshots = r.Result.ConfigSnapshots - s.ResultFileIDs = r.Result.ResultFileIDs + if r.Result.ResultFileIDs == nil { + s.ResultFileIDs = []int64{} + } else { + s.ResultFileIDs = r.Result.ResultFileIDs + } + s.ScenarioID = r.Result.ScenarioID return s @@ -80,7 +85,11 @@ func (r *updateResultRequest) updatedResult(oldResult Result) Result { s := oldResult s.Result.Description = r.Result.Description - s.ResultFileIDs = r.Result.ResultFileIDs + if r.Result.ResultFileIDs == nil { + s.ResultFileIDs = []int64{} + } else { + s.ResultFileIDs = r.Result.ResultFileIDs + } // only update snapshots if not empty var emptyJson postgres.Jsonb