Fix campaign send rate calculation
This commit is contained in:
parent
cf5df3e476
commit
1673cba964
12
campaigns.go
12
campaigns.go
|
@ -386,12 +386,14 @@ func handleGetRunningCampaignStats(c echo.Context) error {
|
||||||
if c.Started.Valid && c.UpdatedAt.Valid {
|
if c.Started.Valid && c.UpdatedAt.Valid {
|
||||||
diff := c.UpdatedAt.Time.Sub(c.Started.Time).Minutes()
|
diff := c.UpdatedAt.Time.Sub(c.Started.Time).Minutes()
|
||||||
if diff > 0 {
|
if diff > 0 {
|
||||||
out[i].Rate = float64(c.Sent) / diff
|
var (
|
||||||
|
sent = float64(c.Sent)
|
||||||
t := float64(c.ToSend)
|
rate = sent / diff
|
||||||
if out[i].Rate > t {
|
)
|
||||||
out[i].Rate = t
|
if rate > sent || rate > float64(c.ToSend) {
|
||||||
|
rate = sent
|
||||||
}
|
}
|
||||||
|
out[i].Rate = rate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue