Skip to content

Commit 45a4a1f

Browse files
committed
better rate calculation
1 parent c587653 commit 45a4a1f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Diff for: indexer.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ func IndexBatch(elasticURL string, index string, batch string) (int, int, error)
179179
// IndexContacts queries and indexes all contacts with a lastModified greater than or equal to the passed in time
180180
func IndexContacts(db *sql.DB, elasticURL string, index string, lastModified time.Time) (int, int, error) {
181181
batch := strings.Builder{}
182-
createdCount, deletedCount := 0, 0
182+
createdCount, deletedCount, processedCount := 0, 0, 0
183183

184184
if index == "" {
185185
return createdCount, deletedCount, fmt.Errorf("empty index passed to IndexContacts")
@@ -215,6 +215,7 @@ func IndexContacts(db *sql.DB, elasticURL string, index string, lastModified tim
215215
}
216216

217217
queryCount++
218+
processedCount++
218219
lastModified = modifiedOn
219220

220221
if isActive {
@@ -261,7 +262,7 @@ func IndexContacts(db *sql.DB, elasticURL string, index string, lastModified tim
261262
}
262263

263264
elapsed := time.Now().Sub(start)
264-
rate := float32(queryCount) / (float32(elapsed) / float32(time.Second))
265+
rate := float32(processedCount) / (float32(elapsed) / float32(time.Second))
265266
log.WithFields(map[string]interface{}{
266267
"rate": int(rate),
267268
"added": createdCount,

0 commit comments

Comments
 (0)