aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulie Qiu <julie@golang.org>2021-05-03 13:29:02 -0400
committerJulie Qiu <julie@golang.org>2021-05-04 15:55:03 +0000
commit66d09ef2b8fad2fb7d6324b796fc8a96c0ab2cf8 (patch)
tree81cfb811d1acb047d9764a4cbec07c25fcde9041
parent701537b65ccac2b1a1564a60b7df71a3efda7184 (diff)
downloadgo-x-pkgsite-66d09ef2b8fad2fb7d6324b796fc8a96c0ab2cf8.tar.xz
internal: prefix GetSymbolHistory functions with Legacy
The GetSymbolHistory will be rewritten in future CLs to handle cases where symbol names at different build contexts have different SymbolMeta. As a first step, the current functions are prefixed with Legacy. For golang/go#37102 Change-Id: I1553a793784526c4905a4aaa354f320c985a3d02 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/316370 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>
-rw-r--r--internal/frontend/versions.go2
-rw-r--r--internal/postgres/insert_symbol_history.go2
-rw-r--r--internal/postgres/package_symbol.go4
-rw-r--r--internal/postgres/symbol_history.go28
-rw-r--r--internal/postgres/symbol_test.go8
-rw-r--r--internal/postgres/unit.go2
-rw-r--r--internal/symbol/compare.go2
-rw-r--r--internal/symbol/intro.go4
-rw-r--r--internal/symbol/intro_test.go4
9 files changed, 28 insertions, 28 deletions
diff --git a/internal/frontend/versions.go b/internal/frontend/versions.go
index 1232a86e..6978ac04 100644
--- a/internal/frontend/versions.go
+++ b/internal/frontend/versions.go
@@ -94,7 +94,7 @@ func fetchVersionsDetails(ctx context.Context, ds internal.DataSource, fullPath,
outVersionToNameToUnitSymbol := map[string]map[string]*internal.UnitSymbol{}
if experiment.IsActive(ctx, internal.ExperimentSymbolHistoryVersionsPage) {
- outVersionToNameToUnitSymbol, err = db.GetSymbolHistory(ctx, fullPath, modulePath)
+ outVersionToNameToUnitSymbol, err = db.LegacyGetSymbolHistory(ctx, fullPath, modulePath)
if err != nil {
return nil, err
}
diff --git a/internal/postgres/insert_symbol_history.go b/internal/postgres/insert_symbol_history.go
index fc226837..19b41e2d 100644
--- a/internal/postgres/insert_symbol_history.go
+++ b/internal/postgres/insert_symbol_history.go
@@ -37,7 +37,7 @@ func upsertSymbolHistory(ctx context.Context, ddb *database.DB,
return err
}
for packagePath, docIDToDoc := range pathToDocIDToDoc {
- dbVersionToNameToUnitSymbol, err := GetSymbolHistoryFromTable(ctx, ddb, packagePath, modulePath)
+ dbVersionToNameToUnitSymbol, err := LegacyGetSymbolHistoryFromTable(ctx, ddb, packagePath, modulePath)
if err != nil {
return err
}
diff --git a/internal/postgres/package_symbol.go b/internal/postgres/package_symbol.go
index 5b6a0cbf..0227a51a 100644
--- a/internal/postgres/package_symbol.go
+++ b/internal/postgres/package_symbol.go
@@ -15,8 +15,8 @@ import (
"golang.org/x/pkgsite/internal/middleware"
)
-// getPackageSymbols returns all of the symbols for a given package path and module path.
-func getPackageSymbols(ctx context.Context, ddb *database.DB, packagePath, modulePath string,
+// legacyGetPackageSymbols returns all of the symbols for a given package path and module path.
+func legacyGetPackageSymbols(ctx context.Context, ddb *database.DB, packagePath, modulePath string,
) (_ map[string]map[string]*internal.UnitSymbol, err error) {
defer derrors.Wrap(&err, "getPackageSymbols(ctx, ddb, %q, %q)", packagePath, modulePath)
defer middleware.ElapsedStat(ctx, "getPackageSymbols")()
diff --git a/internal/postgres/symbol_history.go b/internal/postgres/symbol_history.go
index 50c03c5e..ab9df5f9 100644
--- a/internal/postgres/symbol_history.go
+++ b/internal/postgres/symbol_history.go
@@ -18,25 +18,25 @@ import (
"golang.org/x/pkgsite/internal/symbol"
)
-// GetSymbolHistory returns a map of the first version when a symbol name is
+// LegacyGetSymbolHistory returns a map of the first version when a symbol name is
// added to the API, to the symbol name, to the UnitSymbol struct. The
// UnitSymbol.Children field will always be empty, as children names are also
// tracked.
-func (db *DB) GetSymbolHistory(ctx context.Context, packagePath, modulePath string,
+func (db *DB) LegacyGetSymbolHistory(ctx context.Context, packagePath, modulePath string,
) (_ map[string]map[string]*internal.UnitSymbol, err error) {
- defer derrors.Wrap(&err, "GetSymbolHistory(ctx, %q, %q)", packagePath, modulePath)
- defer middleware.ElapsedStat(ctx, "GetSymbolHistory")()
+ defer derrors.Wrap(&err, "LegacyGetSymbolHistory(ctx, %q, %q)", packagePath, modulePath)
+ defer middleware.ElapsedStat(ctx, "LegacyGetSymbolHistory")()
if experiment.IsActive(ctx, internal.ExperimentReadSymbolHistory) {
- return GetSymbolHistoryFromTable(ctx, db.db, packagePath, modulePath)
+ return LegacyGetSymbolHistoryFromTable(ctx, db.db, packagePath, modulePath)
}
- return GetSymbolHistoryWithPackageSymbols(ctx, db.db, packagePath, modulePath)
+ return LegacyGetSymbolHistoryWithPackageSymbols(ctx, db.db, packagePath, modulePath)
}
-// GetSymbolHistoryFromTable fetches symbol history data from the symbol_history table.
+// LegacyGetSymbolHistoryFromTable fetches symbol history data from the symbol_history table.
//
-// GetSymbolHistoryFromTable is exported for use in tests.
-func GetSymbolHistoryFromTable(ctx context.Context, ddb *database.DB,
+// LegacyGetSymbolHistoryFromTable is exported for use in tests.
+func LegacyGetSymbolHistoryFromTable(ctx context.Context, ddb *database.DB,
packagePath, modulePath string) (_ map[string]map[string]*internal.UnitSymbol, err error) {
defer derrors.WrapStack(&err, "GetSymbolHistoryFromTable(ctx, ddb, %q, %q)", packagePath, modulePath)
@@ -102,20 +102,20 @@ func GetSymbolHistoryFromTable(ctx context.Context, ddb *database.DB,
return versionToNameToUnitSymbol, nil
}
-// GetSymbolHistoryWithPackageSymbols fetches symbol history data by using data
+// LegacyGetSymbolHistoryWithPackageSymbols fetches symbol history data by using data
// from package_symbols and documentation_symbols, and computed using
// symbol.IntroducedHistory.
//
-// GetSymbolHistoryWithPackageSymbols is exported for use in tests.
-func GetSymbolHistoryWithPackageSymbols(ctx context.Context, ddb *database.DB,
+// LegacyGetSymbolHistoryWithPackageSymbols is exported for use in tests.
+func LegacyGetSymbolHistoryWithPackageSymbols(ctx context.Context, ddb *database.DB,
packagePath, modulePath string) (_ map[string]map[string]*internal.UnitSymbol, err error) {
defer derrors.WrapStack(&err, "GetSymbolHistoryWithPackageSymbols(ctx, ddb, %q, %q)", packagePath, modulePath)
defer middleware.ElapsedStat(ctx, "GetSymbolHistoryWithPackageSymbols")()
- versionToNameToUnitSymbols, err := getPackageSymbols(ctx, ddb, packagePath, modulePath)
+ versionToNameToUnitSymbols, err := legacyGetPackageSymbols(ctx, ddb, packagePath, modulePath)
if err != nil {
return nil, err
}
- return symbol.IntroducedHistory(versionToNameToUnitSymbols), nil
+ return symbol.LegacyIntroducedHistory(versionToNameToUnitSymbols), nil
}
// getSymbolHistoryForBuildContext returns a map of the first version when a symbol name is
diff --git a/internal/postgres/symbol_test.go b/internal/postgres/symbol_test.go
index 04d42a63..6c212245 100644
--- a/internal/postgres/symbol_test.go
+++ b/internal/postgres/symbol_test.go
@@ -67,7 +67,7 @@ func TestInsertSymbolNamesAndHistory(t *testing.T) {
want2[mod.Version] = unitSymbolsFromAPI(api, mod.Version)
comparePackageSymbols(ctx, t, testDB, mod.Packages()[0].Path, mod.ModulePath, mod.Version, want2)
- gotHist, err := testDB.GetSymbolHistory(ctx, mod.Packages()[0].Path, mod.ModulePath)
+ gotHist, err := testDB.LegacyGetSymbolHistory(ctx, mod.Packages()[0].Path, mod.ModulePath)
if err != nil {
t.Fatal(err)
}
@@ -202,7 +202,7 @@ func TestInsertSymbolHistory_MultiVersions(t *testing.T) {
}
comparePackageSymbols(ctx, t, testDB, mod10.Packages()[0].Path, mod10.ModulePath, mod10.Version, want2)
- gotHist, err := testDB.GetSymbolHistory(ctx, mod10.Packages()[0].Path, mod10.ModulePath)
+ gotHist, err := testDB.LegacyGetSymbolHistory(ctx, mod10.Packages()[0].Path, mod10.ModulePath)
if err != nil {
t.Fatal(err)
}
@@ -355,7 +355,7 @@ func TestInsertSymbolHistory_MultiGOOS(t *testing.T) {
}
comparePackageSymbols(ctx, t, testDB, mod10.Packages()[0].Path, mod10.ModulePath, mod10.Version, want2)
- gotHist, err := testDB.GetSymbolHistory(ctx, mod10.Packages()[0].Path, mod10.ModulePath)
+ gotHist, err := testDB.LegacyGetSymbolHistory(ctx, mod10.Packages()[0].Path, mod10.ModulePath)
if err != nil {
t.Fatal(err)
}
@@ -475,7 +475,7 @@ func compareUnitSymbols(ctx context.Context, t *testing.T, testDB *DB,
func comparePackageSymbols(ctx context.Context, t *testing.T, testDB *DB,
path, modulePath, version string, want map[string]map[string]*internal.UnitSymbol) {
t.Helper()
- got, err := getPackageSymbols(ctx, testDB.db, path, modulePath)
+ got, err := legacyGetPackageSymbols(ctx, testDB.db, path, modulePath)
if err != nil {
t.Fatal(err)
}
diff --git a/internal/postgres/unit.go b/internal/postgres/unit.go
index 312f80f4..5318df9e 100644
--- a/internal/postgres/unit.go
+++ b/internal/postgres/unit.go
@@ -523,7 +523,7 @@ func (db *DB) getUnitWithAllFields(ctx context.Context, um *internal.UnitMeta, b
return &u, nil
}
- versionToNameToUnitSymbol, err := GetSymbolHistoryWithPackageSymbols(ctx, db.db, um.Path,
+ versionToNameToUnitSymbol, err := LegacyGetSymbolHistoryWithPackageSymbols(ctx, db.db, um.Path,
um.ModulePath)
if err != nil {
return nil, err
diff --git a/internal/symbol/compare.go b/internal/symbol/compare.go
index 463b66e5..ee253568 100644
--- a/internal/symbol/compare.go
+++ b/internal/symbol/compare.go
@@ -18,7 +18,7 @@ import (
// inVersionToNameToUnitSymbol.
func CompareAPIVersions(path string, apiVersions pkgAPIVersions,
inVersionToNameToUnitSymbol map[string]map[string]*internal.UnitSymbol) []string {
- versionToNameToUnitSymbol := IntroducedHistory(inVersionToNameToUnitSymbol)
+ versionToNameToUnitSymbol := LegacyIntroducedHistory(inVersionToNameToUnitSymbol)
// Create a map of name to the first version when the symbol name was found
// in the package.
diff --git a/internal/symbol/intro.go b/internal/symbol/intro.go
index 47e16b90..ae31470a 100644
--- a/internal/symbol/intro.go
+++ b/internal/symbol/intro.go
@@ -11,11 +11,11 @@ import (
"golang.org/x/pkgsite/internal"
)
-// IntroducedHistory returns a map of the first version when a symbol name is
+// LegacyIntroducedHistory returns a map of the first version when a symbol name is
// added to the API, to the symbol name, to the UnitSymbol struct. The
// UnitSymbol.Children field will always be empty, as children names are also
// tracked.
-func IntroducedHistory(versionToNameToUnitSymbol map[string]map[string]*internal.UnitSymbol) (
+func LegacyIntroducedHistory(versionToNameToUnitSymbol map[string]map[string]*internal.UnitSymbol) (
outVersionToNameToUnitSymbol map[string]map[string]*internal.UnitSymbol) {
// Create an array of the versions in versionToNameToUnitSymbol, sorted by
// increasing semver.
diff --git a/internal/symbol/intro_test.go b/internal/symbol/intro_test.go
index 49703418..946209eb 100644
--- a/internal/symbol/intro_test.go
+++ b/internal/symbol/intro_test.go
@@ -58,7 +58,7 @@ func TestIntroducedHistory_OneBuildContext(t *testing.T) {
},
},
}
- got := IntroducedHistory(input)
+ got := LegacyIntroducedHistory(input)
if diff := cmp.Diff(want, got, cmpopts.IgnoreFields(internal.UnitSymbol{}, "builds")); diff != "" {
t.Errorf("mismatch (-want, +got):\n%s", diff)
}
@@ -127,7 +127,7 @@ func TestIntroducedHistory_MultiGOOS(t *testing.T) {
"Foo.A": withBuilds("Foo.A", internal.BuildContextJS),
},
}
- got := IntroducedHistory(input)
+ got := LegacyIntroducedHistory(input)
if diff := cmp.Diff(want, got, cmpopts.IgnoreFields(internal.UnitSymbol{}, "builds")); diff != "" {
t.Errorf("mismatch (-want, +got):\n%s", diff)
}