Skip to content

Commit

Permalink
Handle edge cases in seat demand stats
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Spreitzer <[email protected]>
  • Loading branch information
MikeSpreitzer authored and Swizzmaster committed Dec 28, 2023
1 parent da842e4 commit dcf4c17
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,15 @@ type seatDemandStats struct {
}

func (stats *seatDemandStats) update(obs fq.IntegratorResults) {
stats.highWatermark = obs.Max
if obs.Duration <= 0 {
return
}
if math.IsNaN(obs.Deviation) {
obs.Deviation = 0
}
stats.avg = obs.Average
stats.stdDev = obs.Deviation
stats.highWatermark = obs.Max
envelope := obs.Average + obs.Deviation
stats.smoothed = math.Max(envelope, seatDemandSmoothingCoefficient*stats.smoothed+(1-seatDemandSmoothingCoefficient)*envelope)
}
Expand Down

0 comments on commit dcf4c17

Please sign in to comment.