diff options
| author | Julie Qiu <julie@golang.org> | 2021-05-04 18:25:06 -0400 |
|---|---|---|
| committer | Julie Qiu <julie@golang.org> | 2021-05-05 16:28:30 +0000 |
| commit | c565cc5c7ee418dc50c392bfd989e74ae1816d4a (patch) | |
| tree | 8f44ff54e45a1db7460ef81d53a674f49cdcc151 /internal/postgres | |
| parent | d27e17ce177da6ba1b9aa01c44b4952fd8376ee3 (diff) | |
| download | go-x-pkgsite-c565cc5c7ee418dc50c392bfd989e74ae1816d4a.tar.xz | |
internal/postgres: only fetch symbol history for packages
The symbol history should only be fetched when a unit is a package.
Otherwise, there won't be use for that data on the main page.
For golang/go#37102
Change-Id: Icac3931ca743fade37f71afab219b56c70cf6392
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/317011
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Diffstat (limited to 'internal/postgres')
| -rw-r--r-- | internal/postgres/unit.go | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/internal/postgres/unit.go b/internal/postgres/unit.go index 5318df9e..9e431ff6 100644 --- a/internal/postgres/unit.go +++ b/internal/postgres/unit.go @@ -515,26 +515,29 @@ func (db *DB) getUnitWithAllFields(ctx context.Context, um *internal.UnitMeta, b if !experiment.IsActive(ctx, internal.ExperimentSymbolHistoryMainPage) { return &u, nil } - if experiment.IsActive(ctx, internal.ExperimentReadSymbolHistory) { - u.SymbolHistory, err = getSymbolHistoryForBuildContext(ctx, db.db, pathID, um.ModulePath, bcMatched) + if um.IsPackage() && doc.Source != nil { + if experiment.IsActive(ctx, internal.ExperimentReadSymbolHistory) { + u.SymbolHistory, err = getSymbolHistoryForBuildContext(ctx, db.db, pathID, um.ModulePath, bcMatched) + if err != nil { + return nil, err + } + + return &u, nil + } + + versionToNameToUnitSymbol, err := LegacyGetSymbolHistoryWithPackageSymbols(ctx, db.db, um.Path, + um.ModulePath) if err != nil { return nil, err } - return &u, nil - } - - versionToNameToUnitSymbol, err := LegacyGetSymbolHistoryWithPackageSymbols(ctx, db.db, um.Path, - um.ModulePath) - if err != nil { - return nil, err - } - nameToVersion := map[string]string{} - for v, nts := range versionToNameToUnitSymbol { - for n := range nts { - nameToVersion[n] = v + nameToVersion := map[string]string{} + for v, nts := range versionToNameToUnitSymbol { + for n := range nts { + nameToVersion[n] = v + } } + u.SymbolHistory = nameToVersion } - u.SymbolHistory = nameToVersion return &u, nil } |
