Fix campaign send rate calculation

This commit is contained in:
Kailash Nadh 2018-11-27 11:44:54 +05:30
parent cf5df3e476
commit 1673cba964
1 changed files with 7 additions and 5 deletions

View File

@ -386,12 +386,14 @@ func handleGetRunningCampaignStats(c echo.Context) error {
if c.Started.Valid && c.UpdatedAt.Valid {
diff := c.UpdatedAt.Time.Sub(c.Started.Time).Minutes()
if diff > 0 {
out[i].Rate = float64(c.Sent) / diff
t := float64(c.ToSend)
if out[i].Rate > t {
out[i].Rate = t
var (
sent = float64(c.Sent)
rate = sent / diff
)
if rate > sent || rate > float64(c.ToSend) {
rate = sent
}
out[i].Rate = rate
}
}
}