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>
diff --git a/internal/frontend/versions.go b/internal/frontend/versions.go
index 1232a86..6978ac0 100644
--- a/internal/frontend/versions.go
+++ b/internal/frontend/versions.go
@@ -94,7 +94,7 @@
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 fc22683..19b41e2 100644
--- a/internal/postgres/insert_symbol_history.go
+++ b/internal/postgres/insert_symbol_history.go
@@ -37,7 +37,7 @@
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 5b6a0cb..0227a51 100644
--- a/internal/postgres/package_symbol.go
+++ b/internal/postgres/package_symbol.go
@@ -15,8 +15,8 @@
"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 50c03c5..ab9df5f 100644
--- a/internal/postgres/symbol_history.go
+++ b/internal/postgres/symbol_history.go
@@ -18,25 +18,25 @@
"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 @@
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 04d42a6..6c21224 100644
--- a/internal/postgres/symbol_test.go
+++ b/internal/postgres/symbol_test.go
@@ -67,7 +67,7 @@
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 @@
}
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 @@
}
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 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 312f80f..5318df9 100644
--- a/internal/postgres/unit.go
+++ b/internal/postgres/unit.go
@@ -523,7 +523,7 @@
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 463b66e..ee25356 100644
--- a/internal/symbol/compare.go
+++ b/internal/symbol/compare.go
@@ -18,7 +18,7 @@
// 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 47e16b9..ae31470 100644
--- a/internal/symbol/intro.go
+++ b/internal/symbol/intro.go
@@ -11,11 +11,11 @@
"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 4970341..946209e 100644
--- a/internal/symbol/intro_test.go
+++ b/internal/symbol/intro_test.go
@@ -58,7 +58,7 @@
},
},
}
- 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 @@
"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)
}