Skip to content

Commit

Permalink
internal/postgres: update only changed counts in search docs
Browse files Browse the repository at this point in the history
When updating imported-by counts, only look at changed counts for
packages in search_documents.

For golang/go#47555

Change-Id: If9a03a747d11bf715de126248aa74e30098b13aa
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/341270
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
Reviewed-by: Julie Qiu <julie@golang.org>
  • Loading branch information
jba committed Aug 10, 2021
1 parent 788d551 commit 4645a4b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions internal/postgres/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -831,12 +831,12 @@ func (db *DB) UpdateSearchDocumentsImportedByCount(ctx context.Context) (nUpdate
if err != nil {
return 0, err
}
// Include only changed counts.
log.Debugf(ctx, "update-imported-by-counts: got %d counts", len(newCounts))
// Include only changed counts for packages that are in search_documents.
changedCounts := map[string]int{}
for p, c := range newCounts {
if curCounts[p] != c {
changedCounts[p] = c
for p, nc := range newCounts {
cc, present := curCounts[p]
if present && cc != nc {
changedCounts[p] = nc
}
}
pct := 0
Expand Down

0 comments on commit 4645a4b

Please sign in to comment.