mirror of
https://github.com/status-im/fathom.git
synced 2025-03-01 03:20:27 +00:00
limit buffer capacity to 99 pageviews, hotfix for #132
This commit is contained in:
parent
966a4addab
commit
d116f1fd70
@ -27,8 +27,8 @@ type Collector struct {
|
||||
}
|
||||
|
||||
func NewCollector(store datastore.Datastore) *Collector {
|
||||
bufferCap := 512 // persist every 512 pageviews
|
||||
bufferTimeout := 600 * time.Millisecond // or every 600ms
|
||||
bufferCap := 90 // persist every 90 pageviews, see https://github.com/usefathom/fathom/issues/132
|
||||
bufferTimeout := 900 * time.Millisecond // or every 900 ms, whichever comes first
|
||||
|
||||
c := &Collector{
|
||||
Store: store,
|
||||
|
@ -33,17 +33,19 @@ func (db *sqlstore) InsertPageviews(pageviews []*models.Pageview) error {
|
||||
}
|
||||
|
||||
// generate placeholders string
|
||||
placeholders := strings.Repeat("(?, ?, ?, ?, ?, ?, ?, ?, ?, ?),", n)
|
||||
placeholderTemplate := "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?),"
|
||||
placeholders := strings.Repeat(placeholderTemplate, n)
|
||||
placeholders = placeholders[:len(placeholders)-1]
|
||||
nPlaceholders := strings.Count(placeholderTemplate, "?")
|
||||
|
||||
// init values slice with correct length
|
||||
nValues := n * 10
|
||||
nValues := n * nPlaceholders
|
||||
values := make([]interface{}, nValues)
|
||||
|
||||
// overwrite nil values in slice
|
||||
j := 0
|
||||
for i := range pageviews {
|
||||
j = i * 10
|
||||
j = i * nPlaceholders
|
||||
values[j] = pageviews[i].ID
|
||||
values[j+1] = pageviews[i].Hostname
|
||||
values[j+2] = pageviews[i].Pathname
|
||||
|
Loading…
x
Reference in New Issue
Block a user