Skip to content

Commit b6c7098

Browse files
committed
many: remove "retractions" experiment
For golang/go#43265 Change-Id: Iac39814ce532adf5846bb768802a46ad7a77fa84 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/309609 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
1 parent b0d7b43 commit b6c7098

File tree

9 files changed

+63
-86
lines changed

9 files changed

+63
-86
lines changed

content/static/html/helpers/_unit_header.tmpl

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -203,27 +203,25 @@
203203
</span>
204204
</div>
205205
{{end}}
206-
{{if (.Experiments.IsActive "retractions")}}
207-
{{if .Unit.Deprecated}}
208-
<div class="UnitHeader-banner UnitHeader-banner--deprecated">
209-
<span class="Site-margin UnitHeader-bannerContent">
210-
<strong>Deprecated</strong>
211-
{{with .Unit.DeprecationComment}}
212-
<strong>:</strong>&nbsp;{{.}}
213-
{{end}}
214-
</span>
215-
</div>
216-
{{end}}
217-
{{if .Unit.Retracted}}
218-
<div class="UnitHeader-banner UnitHeader-banner--retracted">
219-
<span class="Site-margin UnitHeader-bannerContent">
220-
<strong>Retracted</strong>
221-
{{with .Unit.RetractionRationale}}
222-
<strong>:</strong>&nbsp;{{.}}
223-
{{end}}
224-
</span>
225-
</div>
226-
{{end}}
206+
{{if .Unit.Deprecated}}
207+
<div class="UnitHeader-banner UnitHeader-banner--deprecated">
208+
<span class="Site-margin UnitHeader-bannerContent">
209+
<strong>Deprecated</strong>
210+
{{with .Unit.DeprecationComment}}
211+
<strong>:</strong>&nbsp;{{.}}
212+
{{end}}
213+
</span>
214+
</div>
215+
{{end}}
216+
{{if .Unit.Retracted}}
217+
<div class="UnitHeader-banner UnitHeader-banner--retracted">
218+
<span class="Site-margin UnitHeader-bannerContent">
219+
<strong>Retracted</strong>
220+
{{with .Unit.RetractionRationale}}
221+
<strong>:</strong>&nbsp;{{.}}
222+
{{end}}
223+
</span>
224+
</div>
227225
{{end}}
228226
{{if .LatestMajorVersion}}
229227
<div class="UnitHeader-banner UnitHeader-banner--majorVersion" data-test-id="UnitHeader-majorVersionBanner">

internal/experiment.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ package internal
77

88
const (
99
ExperimentInsertSymbols = "insert-symbols"
10-
ExperimentRetractions = "retractions"
1110
ExperimentSymbolHistoryVersionsPage = "symbol-history-versions-page"
1211
ExperimentSymbolHistoryMainPage = "symbol-history-main-page"
1312
ExperimentUnitMetaWithLatest = "unit-meta-with-latest"
@@ -17,7 +16,6 @@ const (
1716
// a description of each experiment.
1817
var Experiments = map[string]string{
1918
ExperimentInsertSymbols: "Insert data into symbols, package_symbols, and documentation_symbols.",
20-
ExperimentRetractions: "Retrieve and display retraction and deprecation information.",
2119
ExperimentSymbolHistoryVersionsPage: "Show package API history on the versions page.",
2220
ExperimentSymbolHistoryMainPage: "Show package API history on the main unit page.",
2321
ExperimentUnitMetaWithLatest: "Use latest-version information for GetUnitMeta.",

internal/frontend/versions.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func fetchVersionsDetails(ctx context.Context, ds internal.DataSource, fullPath,
112112
}
113113
return constructUnitURL(versionPath, mi.ModulePath, linkVersion(mi.Version, mi.ModulePath))
114114
}
115-
return buildVersionDetails(ctx, modulePath, versions, outVersionToNameToUnitSymbol, linkify), nil
115+
return buildVersionDetails(modulePath, versions, outVersionToNameToUnitSymbol, linkify), nil
116116
}
117117

118118
// pathInVersion constructs the full import path of the package corresponding
@@ -139,8 +139,7 @@ func pathInVersion(v1Path string, mi *internal.ModuleInfo) string {
139139
// versions tab, organizing major versions into those that have the same module
140140
// path as the package version under consideration, and those that don't. The
141141
// given versions MUST be sorted first by module path and then by semver.
142-
func buildVersionDetails(ctx context.Context,
143-
currentModulePath string,
142+
func buildVersionDetails(currentModulePath string,
144143
modInfos []*internal.ModuleInfo,
145144
versionToNameToSymbol map[string]map[string]*internal.UnitSymbol,
146145
linkify func(v *internal.ModuleInfo) string) *VersionsDetails {
@@ -187,12 +186,10 @@ func buildVersionDetails(ctx context.Context,
187186
Version: linkVersion(mi.Version, mi.ModulePath),
188187
IsMinor: isMinor(mi.Version),
189188
}
190-
if experiment.IsActive(ctx, internal.ExperimentRetractions) {
191-
key.Deprecated = mi.Deprecated
192-
key.DeprecationComment = shortRationale(mi.DeprecationComment)
193-
vs.Retracted = mi.Retracted
194-
vs.RetractionRationale = shortRationale(mi.RetractionRationale)
195-
}
189+
key.Deprecated = mi.Deprecated
190+
key.DeprecationComment = shortRationale(mi.DeprecationComment)
191+
vs.Retracted = mi.Retracted
192+
vs.RetractionRationale = shortRationale(mi.RetractionRationale)
196193
if nts, ok := versionToNameToSymbol[mi.Version]; ok {
197194
vs.Symbols = symbolsForVersion(linkify(mi), nts)
198195
}

internal/postgres/insert_module_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func TestInsertModule(t *testing.T) {
3737
for _, test := range []struct {
3838
name string
3939
module *internal.Module
40+
goMod string
4041
}{
4142
{
4243
name: "valid test",
@@ -74,15 +75,16 @@ func TestInsertModule(t *testing.T) {
7475
m.DeprecationComment = "use v2"
7576
return m
7677
}(),
78+
goMod: "module " + sample.ModulePath + " // Deprecated: use v2",
7779
},
7880
} {
7981
t.Run(test.name, func(t *testing.T) {
8082
testDB, release := acquire(t)
8183
defer release()
8284

83-
MustInsertModule(ctx, t, testDB, test.module)
85+
MustInsertModuleGoMod(ctx, t, testDB, test.module, test.goMod)
8486
// Test that insertion of duplicate primary key won't fail.
85-
MustInsertModule(ctx, t, testDB, test.module)
87+
MustInsertModuleGoMod(ctx, t, testDB, test.module, test.goMod)
8688
checkModule(ctx, t, testDB, test.module)
8789
})
8890
}

internal/postgres/unit.go

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -124,21 +124,19 @@ func (db *DB) getUnitMetaWithKnownLatestVersion(ctx context.Context, fullPath, m
124124
}
125125
um.Licenses = lics
126126

127-
if experiment.IsActive(ctx, internal.ExperimentRetractions) {
128-
// If we don't have the latest version information, try to get it.
129-
// We can be here if there is really no info (in which case we are repeating
130-
// some work, but it's fast), or if we are ignoring the info (for instance,
131-
// if all versions were retracted).
132-
if lmv == nil {
133-
lmv, err = db.GetLatestModuleVersions(ctx, um.ModulePath)
134-
if err != nil {
135-
return nil, err
136-
}
137-
}
138-
if lmv != nil {
139-
lmv.PopulateModuleInfo(&um.ModuleInfo)
127+
// If we don't have the latest version information, try to get it.
128+
// We can be here if there is really no info (in which case we are repeating
129+
// some work, but it's fast), or if we are ignoring the info (for instance,
130+
// if all versions were retracted).
131+
if lmv == nil {
132+
lmv, err = db.GetLatestModuleVersions(ctx, um.ModulePath)
133+
if err != nil {
134+
return nil, err
140135
}
141136
}
137+
if lmv != nil {
138+
lmv.PopulateModuleInfo(&um.ModuleInfo)
139+
}
142140
return &um, nil
143141
}
144142

internal/postgres/unit_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,11 @@ func TestGetUnitMeta(t *testing.T) {
2626
t.Parallel()
2727
ctx, cancel := context.WithTimeout(context.Background(), testTimeout*2)
2828
defer cancel()
29-
ctx = experiment.NewContext(ctx, internal.ExperimentRetractions)
3029
t.Run("legacy", func(t *testing.T) {
3130
testGetUnitMeta(t, ctx)
3231
})
3332
t.Run("latest", func(t *testing.T) {
34-
testGetUnitMeta(t, experiment.NewContext(ctx,
35-
internal.ExperimentRetractions, internal.ExperimentUnitMetaWithLatest))
33+
testGetUnitMeta(t, experiment.NewContext(ctx, internal.ExperimentUnitMetaWithLatest))
3634
})
3735
}
3836

@@ -295,7 +293,7 @@ func TestGetUnitMetaDiffs(t *testing.T) {
295293
if got := modver(gotLegacy); got != test.wantLegacy {
296294
t.Errorf("legacy: got %s, want %s", got, test.wantLegacy)
297295
}
298-
gotLatest, err := testDB.GetUnitMeta(experiment.NewContext(ctx, internal.ExperimentRetractions, internal.ExperimentUnitMetaWithLatest),
296+
gotLatest, err := testDB.GetUnitMeta(experiment.NewContext(ctx, internal.ExperimentUnitMetaWithLatest),
299297
test.path, internal.UnknownModulePath, internal.LatestVersion)
300298
if err != nil {
301299
t.Fatal(err)

internal/postgres/version.go

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@ import (
1010
"errors"
1111
"fmt"
1212
"strings"
13-
"time"
1413

1514
"github.com/Masterminds/squirrel"
1615
"github.com/lib/pq"
1716
"golang.org/x/mod/semver"
1817
"golang.org/x/pkgsite/internal"
1918
"golang.org/x/pkgsite/internal/database"
2019
"golang.org/x/pkgsite/internal/derrors"
21-
"golang.org/x/pkgsite/internal/experiment"
2220
"golang.org/x/pkgsite/internal/log"
2321
"golang.org/x/pkgsite/internal/version"
2422
"golang.org/x/sync/errgroup"
@@ -115,45 +113,37 @@ func versionTypeExpr(vts []version.Type) string {
115113
func populateLatestInfo(ctx context.Context, db *DB, mi *internal.ModuleInfo) (err error) {
116114
defer derrors.WrapStack(&err, "populateLatestInfo(%q)", mi.ModulePath)
117115

118-
if experiment.IsActive(ctx, internal.ExperimentRetractions) {
119-
// Get information about retractions an deprecations, and apply it.
120-
start := time.Now()
121-
lmv, err := db.GetLatestModuleVersions(ctx, mi.ModulePath)
122-
if err != nil {
123-
return err
124-
}
125-
if lmv != nil {
126-
lmv.PopulateModuleInfo(mi)
127-
}
128-
log.Debugf(ctx, "latest info fetched and applied in %dms", time.Since(start).Milliseconds())
116+
// Get information about retractions an deprecations, and apply it.
117+
lmv, err := db.GetLatestModuleVersions(ctx, mi.ModulePath)
118+
if err != nil {
119+
return err
120+
}
121+
if lmv != nil {
122+
lmv.PopulateModuleInfo(mi)
129123
}
130124
return nil
131125
}
132126

133127
func populateLatestInfos(ctx context.Context, db *DB, mis []*internal.ModuleInfo) (err error) {
134128
defer derrors.WrapStack(&err, "populateLatestInfos(%d ModuleInfos)", len(mis))
135129

136-
if experiment.IsActive(ctx, internal.ExperimentRetractions) {
137-
start := time.Now()
138-
// Collect the LatestModuleVersions for all modules in the list.
139-
lmvs := map[string]*internal.LatestModuleVersions{}
140-
for _, mi := range mis {
141-
if _, ok := lmvs[mi.ModulePath]; !ok {
142-
lmv, err := db.GetLatestModuleVersions(ctx, mi.ModulePath)
143-
if err != nil {
144-
return err
145-
}
146-
lmvs[mi.ModulePath] = lmv
130+
// Collect the LatestModuleVersions for all modules in the list.
131+
lmvs := map[string]*internal.LatestModuleVersions{}
132+
for _, mi := range mis {
133+
if _, ok := lmvs[mi.ModulePath]; !ok {
134+
lmv, err := db.GetLatestModuleVersions(ctx, mi.ModulePath)
135+
if err != nil {
136+
return err
147137
}
138+
lmvs[mi.ModulePath] = lmv
148139
}
149-
// Use the collected LatestModuleVersions to populate the ModuleInfos.
150-
for _, mi := range mis {
151-
lmv := lmvs[mi.ModulePath]
152-
if lmv != nil {
153-
lmv.PopulateModuleInfo(mi)
154-
}
140+
}
141+
// Use the collected LatestModuleVersions to populate the ModuleInfos.
142+
for _, mi := range mis {
143+
lmv := lmvs[mi.ModulePath]
144+
if lmv != nil {
145+
lmv.PopulateModuleInfo(mi)
155146
}
156-
log.Debugf(ctx, "latest info fetched and applied in %dms", time.Since(start).Milliseconds())
157147
}
158148
return nil
159149
}

internal/postgres/version_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212

1313
"github.com/google/go-cmp/cmp"
1414
"golang.org/x/pkgsite/internal"
15-
"golang.org/x/pkgsite/internal/experiment"
1615
"golang.org/x/pkgsite/internal/source"
1716
"golang.org/x/pkgsite/internal/stdlib"
1817
"golang.org/x/pkgsite/internal/testing/sample"
@@ -231,7 +230,6 @@ func TestGetVersions(t *testing.T) {
231230
},
232231
}
233232

234-
ctx = experiment.NewContext(ctx, internal.ExperimentRetractions)
235233
for _, test := range testCases {
236234
t.Run(test.name, func(t *testing.T) {
237235
for _, w := range test.want {

internal/testing/integration/integration_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"github.com/google/go-cmp/cmp"
1919
"github.com/google/safehtml/template"
2020
"golang.org/x/pkgsite/internal"
21-
"golang.org/x/pkgsite/internal/experiment"
2221
"golang.org/x/pkgsite/internal/godoc/dochtml"
2322
"golang.org/x/pkgsite/internal/index"
2423
"golang.org/x/pkgsite/internal/middleware"
@@ -40,7 +39,6 @@ func TestMain(m *testing.M) {
4039
func TestEndToEndProcessing(t *testing.T) {
4140
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
4241
defer cancel()
43-
ctx = experiment.NewContext(ctx, internal.ExperimentRetractions)
4442

4543
defer postgres.ResetTestDB(testDB, t)
4644

0 commit comments

Comments
 (0)