# HG changeset patch # User Sascha L. Teichmann # Date 1558621530 -7200 # Node ID 4b303c149db41c36f5c26919fcdb28cce288fad3 # Parent cb2f67a07400a2d4685a54a1a1bf004ebc8d5d65 fairway availibilty: Changed result document to be more precise. diff -r cb2f67a07400 -r 4b303c149db4 pkg/controllers/bottlenecks.go --- a/pkg/controllers/bottlenecks.go Thu May 23 15:58:12 2019 +0200 +++ b/pkg/controllers/bottlenecks.go Thu May 23 16:25:30 2019 +0200 @@ -460,36 +460,47 @@ lnwlPercents := durationsToPercentage(from, to, lnwl) afdPercents := durationsToPercentage(from, to, afd) - type lnwlOutput struct { - Level string `json:"level"` - Value float64 `json:"value"` - Percent float64 `json:"percent"` + log.Printf("%v\n", lnwlPercents) + log.Printf("%v\n", afdPercents) + + type ldcOutput struct { + Value float64 `json:"value"` + Below float64 `json:"below"` + Above float64 `json:"above"` } - type afdOutput struct { + type intervalOutput struct { + Type string `json:"type"` Value float64 `json:"value"` Percent float64 `json:"percent"` } type output struct { - LNWL []lnwlOutput `json:"lnwl"` - AFD []afdOutput `json:"afd"` + LDC []intervalOutput `json:"ldc"` + AFD []intervalOutput `json:"afd"` + } + + out := output{ + LDC: []intervalOutput{ + {Type: "below", Value: ldcRefs[0], Percent: lnwlPercents[0]}, + {Type: "above", Value: ldcRefs[0], Percent: lnwlPercents[1]}, + }, } - out := output{} - - for i := range ldcRefs { - out.LNWL = append(out.LNWL, lnwlOutput{ - Level: "LDC", - Value: ldcRefs[i], - Percent: lnwlPercents[i], - }) - } - - for i := range breaks { - out.AFD = append(out.AFD, afdOutput{ - Value: breaks[i], - Percent: afdPercents[i], + for i, percent := range afdPercents { + var typ string + var value float64 + if i != len(afdPercents)-1 { + typ = "below" + value = breaks[i] + } else { + typ = "above" + value = breaks[len(breaks)-1] + } + out.AFD = append(out.AFD, intervalOutput{ + Type: typ, + Value: value, + Percent: percent, }) } @@ -497,6 +508,14 @@ return } +/* + +{ "type": "below", "value": 230, "percent": 0 }, +{ "below": 250, "value": 9 } +{ "above": 250, "value": 8.1 + +*/ + func intervalMode(mode string) int { switch strings.ToLower(mode) { case "monthly":