Skip to content

Commit 66d09ef

Browse files
committed
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 <[email protected]> Run-TryBot: Julie Qiu <[email protected]> TryBot-Result: kokoro <[email protected]> Reviewed-by: Jonathan Amsterdam <[email protected]>
1 parent 701537b commit 66d09ef

File tree

9 files changed

+28
-28
lines changed

9 files changed

+28
-28
lines changed

internal/frontend/versions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func fetchVersionsDetails(ctx context.Context, ds internal.DataSource, fullPath,
9494

9595
outVersionToNameToUnitSymbol := map[string]map[string]*internal.UnitSymbol{}
9696
if experiment.IsActive(ctx, internal.ExperimentSymbolHistoryVersionsPage) {
97-
outVersionToNameToUnitSymbol, err = db.GetSymbolHistory(ctx, fullPath, modulePath)
97+
outVersionToNameToUnitSymbol, err = db.LegacyGetSymbolHistory(ctx, fullPath, modulePath)
9898
if err != nil {
9999
return nil, err
100100
}

internal/postgres/insert_symbol_history.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func upsertSymbolHistory(ctx context.Context, ddb *database.DB,
3737
return err
3838
}
3939
for packagePath, docIDToDoc := range pathToDocIDToDoc {
40-
dbVersionToNameToUnitSymbol, err := GetSymbolHistoryFromTable(ctx, ddb, packagePath, modulePath)
40+
dbVersionToNameToUnitSymbol, err := LegacyGetSymbolHistoryFromTable(ctx, ddb, packagePath, modulePath)
4141
if err != nil {
4242
return err
4343
}

internal/postgres/package_symbol.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import (
1515
"golang.org/x/pkgsite/internal/middleware"
1616
)
1717

18-
// getPackageSymbols returns all of the symbols for a given package path and module path.
19-
func getPackageSymbols(ctx context.Context, ddb *database.DB, packagePath, modulePath string,
18+
// legacyGetPackageSymbols returns all of the symbols for a given package path and module path.
19+
func legacyGetPackageSymbols(ctx context.Context, ddb *database.DB, packagePath, modulePath string,
2020
) (_ map[string]map[string]*internal.UnitSymbol, err error) {
2121
defer derrors.Wrap(&err, "getPackageSymbols(ctx, ddb, %q, %q)", packagePath, modulePath)
2222
defer middleware.ElapsedStat(ctx, "getPackageSymbols")()

internal/postgres/symbol_history.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,25 @@ import (
1818
"golang.org/x/pkgsite/internal/symbol"
1919
)
2020

21-
// GetSymbolHistory returns a map of the first version when a symbol name is
21+
// LegacyGetSymbolHistory returns a map of the first version when a symbol name is
2222
// added to the API, to the symbol name, to the UnitSymbol struct. The
2323
// UnitSymbol.Children field will always be empty, as children names are also
2424
// tracked.
25-
func (db *DB) GetSymbolHistory(ctx context.Context, packagePath, modulePath string,
25+
func (db *DB) LegacyGetSymbolHistory(ctx context.Context, packagePath, modulePath string,
2626
) (_ map[string]map[string]*internal.UnitSymbol, err error) {
27-
defer derrors.Wrap(&err, "GetSymbolHistory(ctx, %q, %q)", packagePath, modulePath)
28-
defer middleware.ElapsedStat(ctx, "GetSymbolHistory")()
27+
defer derrors.Wrap(&err, "LegacyGetSymbolHistory(ctx, %q, %q)", packagePath, modulePath)
28+
defer middleware.ElapsedStat(ctx, "LegacyGetSymbolHistory")()
2929

3030
if experiment.IsActive(ctx, internal.ExperimentReadSymbolHistory) {
31-
return GetSymbolHistoryFromTable(ctx, db.db, packagePath, modulePath)
31+
return LegacyGetSymbolHistoryFromTable(ctx, db.db, packagePath, modulePath)
3232
}
33-
return GetSymbolHistoryWithPackageSymbols(ctx, db.db, packagePath, modulePath)
33+
return LegacyGetSymbolHistoryWithPackageSymbols(ctx, db.db, packagePath, modulePath)
3434
}
3535

36-
// GetSymbolHistoryFromTable fetches symbol history data from the symbol_history table.
36+
// LegacyGetSymbolHistoryFromTable fetches symbol history data from the symbol_history table.
3737
//
38-
// GetSymbolHistoryFromTable is exported for use in tests.
39-
func GetSymbolHistoryFromTable(ctx context.Context, ddb *database.DB,
38+
// LegacyGetSymbolHistoryFromTable is exported for use in tests.
39+
func LegacyGetSymbolHistoryFromTable(ctx context.Context, ddb *database.DB,
4040
packagePath, modulePath string) (_ map[string]map[string]*internal.UnitSymbol, err error) {
4141
defer derrors.WrapStack(&err, "GetSymbolHistoryFromTable(ctx, ddb, %q, %q)", packagePath, modulePath)
4242

@@ -102,20 +102,20 @@ func GetSymbolHistoryFromTable(ctx context.Context, ddb *database.DB,
102102
return versionToNameToUnitSymbol, nil
103103
}
104104

105-
// GetSymbolHistoryWithPackageSymbols fetches symbol history data by using data
105+
// LegacyGetSymbolHistoryWithPackageSymbols fetches symbol history data by using data
106106
// from package_symbols and documentation_symbols, and computed using
107107
// symbol.IntroducedHistory.
108108
//
109-
// GetSymbolHistoryWithPackageSymbols is exported for use in tests.
110-
func GetSymbolHistoryWithPackageSymbols(ctx context.Context, ddb *database.DB,
109+
// LegacyGetSymbolHistoryWithPackageSymbols is exported for use in tests.
110+
func LegacyGetSymbolHistoryWithPackageSymbols(ctx context.Context, ddb *database.DB,
111111
packagePath, modulePath string) (_ map[string]map[string]*internal.UnitSymbol, err error) {
112112
defer derrors.WrapStack(&err, "GetSymbolHistoryWithPackageSymbols(ctx, ddb, %q, %q)", packagePath, modulePath)
113113
defer middleware.ElapsedStat(ctx, "GetSymbolHistoryWithPackageSymbols")()
114-
versionToNameToUnitSymbols, err := getPackageSymbols(ctx, ddb, packagePath, modulePath)
114+
versionToNameToUnitSymbols, err := legacyGetPackageSymbols(ctx, ddb, packagePath, modulePath)
115115
if err != nil {
116116
return nil, err
117117
}
118-
return symbol.IntroducedHistory(versionToNameToUnitSymbols), nil
118+
return symbol.LegacyIntroducedHistory(versionToNameToUnitSymbols), nil
119119
}
120120

121121
// getSymbolHistoryForBuildContext returns a map of the first version when a symbol name is

internal/postgres/symbol_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func TestInsertSymbolNamesAndHistory(t *testing.T) {
6767
want2[mod.Version] = unitSymbolsFromAPI(api, mod.Version)
6868
comparePackageSymbols(ctx, t, testDB, mod.Packages()[0].Path, mod.ModulePath, mod.Version, want2)
6969

70-
gotHist, err := testDB.GetSymbolHistory(ctx, mod.Packages()[0].Path, mod.ModulePath)
70+
gotHist, err := testDB.LegacyGetSymbolHistory(ctx, mod.Packages()[0].Path, mod.ModulePath)
7171
if err != nil {
7272
t.Fatal(err)
7373
}
@@ -202,7 +202,7 @@ func TestInsertSymbolHistory_MultiVersions(t *testing.T) {
202202
}
203203
comparePackageSymbols(ctx, t, testDB, mod10.Packages()[0].Path, mod10.ModulePath, mod10.Version, want2)
204204

205-
gotHist, err := testDB.GetSymbolHistory(ctx, mod10.Packages()[0].Path, mod10.ModulePath)
205+
gotHist, err := testDB.LegacyGetSymbolHistory(ctx, mod10.Packages()[0].Path, mod10.ModulePath)
206206
if err != nil {
207207
t.Fatal(err)
208208
}
@@ -355,7 +355,7 @@ func TestInsertSymbolHistory_MultiGOOS(t *testing.T) {
355355
}
356356
comparePackageSymbols(ctx, t, testDB, mod10.Packages()[0].Path, mod10.ModulePath, mod10.Version, want2)
357357

358-
gotHist, err := testDB.GetSymbolHistory(ctx, mod10.Packages()[0].Path, mod10.ModulePath)
358+
gotHist, err := testDB.LegacyGetSymbolHistory(ctx, mod10.Packages()[0].Path, mod10.ModulePath)
359359
if err != nil {
360360
t.Fatal(err)
361361
}
@@ -475,7 +475,7 @@ func compareUnitSymbols(ctx context.Context, t *testing.T, testDB *DB,
475475
func comparePackageSymbols(ctx context.Context, t *testing.T, testDB *DB,
476476
path, modulePath, version string, want map[string]map[string]*internal.UnitSymbol) {
477477
t.Helper()
478-
got, err := getPackageSymbols(ctx, testDB.db, path, modulePath)
478+
got, err := legacyGetPackageSymbols(ctx, testDB.db, path, modulePath)
479479
if err != nil {
480480
t.Fatal(err)
481481
}

internal/postgres/unit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ func (db *DB) getUnitWithAllFields(ctx context.Context, um *internal.UnitMeta, b
523523
return &u, nil
524524
}
525525

526-
versionToNameToUnitSymbol, err := GetSymbolHistoryWithPackageSymbols(ctx, db.db, um.Path,
526+
versionToNameToUnitSymbol, err := LegacyGetSymbolHistoryWithPackageSymbols(ctx, db.db, um.Path,
527527
um.ModulePath)
528528
if err != nil {
529529
return nil, err

internal/symbol/compare.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
// inVersionToNameToUnitSymbol.
1919
func CompareAPIVersions(path string, apiVersions pkgAPIVersions,
2020
inVersionToNameToUnitSymbol map[string]map[string]*internal.UnitSymbol) []string {
21-
versionToNameToUnitSymbol := IntroducedHistory(inVersionToNameToUnitSymbol)
21+
versionToNameToUnitSymbol := LegacyIntroducedHistory(inVersionToNameToUnitSymbol)
2222

2323
// Create a map of name to the first version when the symbol name was found
2424
// in the package.

internal/symbol/intro.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import (
1111
"golang.org/x/pkgsite/internal"
1212
)
1313

14-
// IntroducedHistory returns a map of the first version when a symbol name is
14+
// LegacyIntroducedHistory returns a map of the first version when a symbol name is
1515
// added to the API, to the symbol name, to the UnitSymbol struct. The
1616
// UnitSymbol.Children field will always be empty, as children names are also
1717
// tracked.
18-
func IntroducedHistory(versionToNameToUnitSymbol map[string]map[string]*internal.UnitSymbol) (
18+
func LegacyIntroducedHistory(versionToNameToUnitSymbol map[string]map[string]*internal.UnitSymbol) (
1919
outVersionToNameToUnitSymbol map[string]map[string]*internal.UnitSymbol) {
2020
// Create an array of the versions in versionToNameToUnitSymbol, sorted by
2121
// increasing semver.

internal/symbol/intro_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func TestIntroducedHistory_OneBuildContext(t *testing.T) {
5858
},
5959
},
6060
}
61-
got := IntroducedHistory(input)
61+
got := LegacyIntroducedHistory(input)
6262
if diff := cmp.Diff(want, got, cmpopts.IgnoreFields(internal.UnitSymbol{}, "builds")); diff != "" {
6363
t.Errorf("mismatch (-want, +got):\n%s", diff)
6464
}
@@ -127,7 +127,7 @@ func TestIntroducedHistory_MultiGOOS(t *testing.T) {
127127
"Foo.A": withBuilds("Foo.A", internal.BuildContextJS),
128128
},
129129
}
130-
got := IntroducedHistory(input)
130+
got := LegacyIntroducedHistory(input)
131131
if diff := cmp.Diff(want, got, cmpopts.IgnoreFields(internal.UnitSymbol{}, "builds")); diff != "" {
132132
t.Errorf("mismatch (-want, +got):\n%s", diff)
133133
}

0 commit comments

Comments
 (0)