Fix a but in add results endpoint, add model and result as optional action params

This commit is contained in:
Sonja Happ 2021-02-23 11:39:04 +01:00
parent 0f0e8872b9
commit efd24023bc
2 changed files with 13 additions and 2 deletions

View file

@ -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 {

View file

@ -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