make sure we get all of it

This commit is contained in:
Andre Medeiros 2023-03-16 12:01:04 -04:00
parent 3c88ab2041
commit 6d0140151b

View file

@ -3,6 +3,7 @@ package cmd
import ( import (
"context" "context"
"fmt" "fmt"
"math"
"net/http" "net/http"
_ "net/http/pprof" _ "net/http/pprof"
"strconv" "strconv"
@ -484,10 +485,14 @@ func enqueueAccounts(ctx context.Context, logger *zap.Logger, statsd *statsd.Cli
} }
chunks := [][]string{} chunks := [][]string{}
chunkSize := int(math.Ceil(float64(len(ids)) / float64(accountEnqueueSeconds)))
for i := 0; i < accountEnqueueSeconds; i++ { for i := 0; i < accountEnqueueSeconds; i++ {
min := (i * len(ids) / accountEnqueueSeconds) left := i * chunkSize
max := ((i + 1) * len(ids)) / accountEnqueueSeconds right := (i + 1) * chunkSize
chunks = append(chunks, ids[min:max]) if right > len(ids) {
right = len(ids)
}
chunks = append(chunks, ids[left:right])
} }
_ = statsd.Histogram("apollo.queue.runtime", float64(time.Since(now).Milliseconds()), []string{"queue:notifications"}, 1) _ = statsd.Histogram("apollo.queue.runtime", float64(time.Since(now).Milliseconds()), []string{"queue:notifications"}, 1)