aboutsummaryrefslogtreecommitdiff
path: root/internal/postgres/unit.go
AgeCommit message (Collapse)Author
2026-03-26internal: consolidate build context and unit resolution logicEthan Lee
- Centralize logic for resolving units and selecting the best matching build context. - New helpers MatchingBuildContext, SortedBuildContexts provide a consistent, efficient approach to build context selection. - DocumentationForBuildContext now finds the best match based on precdence rules rather than just returning the first match. - A new getUnitContext helper resolves unit metadata and the best build context in a single query. - GetSymbols and GetUnit are now both optimized to use pre-resolved IDs, simplifying their queries and removing redundant joins. - Replaced redundant matchingDoc functions in fetchdatasource and fakedatasource. Change-Id: I9207d3bfe03404483c816090a0b99666f14a36e3 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/759162 Reviewed-by: Jonathan Amsterdam <jba@google.com> kokoro-CI: kokoro <noreply+kokoro@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ethan Lee <ethanalee@google.com>
2026-03-24internal/api: implement module packages endpointEthan Lee
- Implement the ServeModulePackages handler and introduce GetModulePackages to return the list of packages for a given module version. Change-Id: I20c1618e2fdbf0126cb913665a1d7457b8951177 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/754863 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> kokoro-CI: kokoro <noreply+kokoro@google.com> Auto-Submit: Ethan Lee <ethanalee@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2026-03-20internal: conditionally return documentation in GetUnitEthan Lee
- Large documentations blobs should avoid being returned unless explicitly requested. Add a WithDocsSource to enable retrieval of unit information without the large documentation source information. - This does not functionally change existing GetUnit callsites. Change-Id: Ie983b7eaeb61bb92f2716ae64a3d1e1ea738dbe2 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/756480 Reviewed-by: Jonathan Amsterdam <jba@google.com> kokoro-CI: kokoro <noreply+kokoro@google.com> Auto-Submit: Ethan Lee <ethanalee@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-02-03internal/postgres: optimize unit metadata lookup for unknown module pathsEthan Lee
When a user requests a package with a symbolic version (e.g., @master) and the module boundary is not yet known, pkgsite currently triggers a "greedy" index scan on the modules table's series_path index to find the best match. This change optimizes the lookup by explicitly providing candidate module paths using internal.CandidateModulePaths. This allows the Postgres optimizer to perform efficient point lookups on the module_path index rather than a linear scan. Fixes golang/go#77367 Change-Id: I072a72dc043ff7fb704977f07ba9fbd4ec821815 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/741300 kokoro-CI: kokoro <noreply+kokoro@google.com> Auto-Submit: Ethan Lee <ethanalee@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-11-17Revert "internal/postgres: utilize num_imports column in insert_module"Ethan Lee
This reverts commit 28eed86815232e48f5e757569fcd061f858142d4. Reason for revert: migration takes too long Change-Id: I279e62342c79d2604cda4e7c9819bdaa8aac752c Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/721101 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> kokoro-CI: kokoro <noreply+kokoro@google.com> Reviewed-by: Robert Findley <rfindley@google.com>
2025-11-13internal/postgres: utilize num_imports column in insert_moduleEthan Lee
- Avoid recomputing number of imports for every query in getUnitWithAllFields. For golang/go#76284 Change-Id: I7f7d683efb1b2ff49e33681802896a65b1354d25 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/720261 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Robert Findley <rfindley@google.com> Auto-Submit: Ethan Lee <ethanalee@google.com> kokoro-CI: kokoro <noreply+kokoro@google.com>
2024-01-23internal: move UnitMeta.IsRedistributable to UnitMichael Matloob
Change-Id: Ia0a18df32d752f20b0400b47860638c7d0910eb7 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/556435 Reviewed-by: Jonathan Amsterdam <jba@google.com> kokoro-CI: kokoro <noreply+kokoro@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Robert Findley <rfindley@google.com>
2024-01-22internal: move UnitMeta.Licenses to UnitMichael Matloob
Change-Id: If2b3c1acd4830948e2d134517608f89771a7abcb Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/555735 kokoro-CI: kokoro <noreply+kokoro@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Robert Findley <rfindley@google.com>
2023-08-04internal/middleware: move stats to its own packageMichael Matloob
Make a package internal/middleware/stats for middleware.Stats and middleware.ElapsedStat. This is part of removing the dependency from internal/frontend on internal/middleware. For golang/go#61399 Change-Id: I44afbfc9b9e28e1caabab8fe700376ec026c863d Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/514521 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org> Reviewed-by: Jamal Carvalho <jamal@golang.org> kokoro-CI: kokoro <noreply+kokoro@google.com>
2022-11-15all: convert interface{} to anyHana (Hyang-Ah) Kim
Change-Id: I1f3b7cc8899c7707abb01e3d14807c37c3451382 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/449695 TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org> Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
2022-04-11all: gofmtRuss Cox
Gofmt to update doc comments to the new formatting. For golang/go#51082. Change-Id: Ia9e71e7ecac75822ff43d6c7e60f512442a5fa50 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/399617 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com> Auto-Submit: Russ Cox <rsc@golang.org> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2022-03-07internal/database: use generics for Collect functionsJonathan Amsterdam
Reimplement some reflection-based collection functions to use generics. In some cases we still need reflection, but at least we can provide a type-safe wrapper with generics. Change-Id: Id95949a7a22ee687166ecdfc1191150d79568889 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/389657 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-08-26internal/postgres: rename functionJonathan Amsterdam
Remove the "Latest" from getUnitMetaWithKnownLatestVersion, because it applies to any known version. Make the error and stat strings match. Change-Id: I805a569ac2180a150c62946980c84263ff3f73ec Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/345250 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-08-20internal,tests: delete symbol history experimentsJulie Qiu
Change-Id: If780b7339dfb415c2060dc1fc9f020a5af57665d Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/343709 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>
2021-08-09internal/postgres: change package_path reference to package_path_idJulie Qiu
The search_documents primary key was changed to package_path_id, so the WHERE clause in GetUnit is updated to match. Change-Id: I8368c5660495fd355267714f0dc64e0ec4ea5a64 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/340398 Trust: Julie Qiu <julie@golang.org> Run-TryBot: Julie Qiu <julie@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-07-30internal: delete ReadSymbolHistory experimentJulie Qiu
The ReadSymbolHistory is deleted, since the symbol_history table has been fully populated. When either ExperimentSymbolHistoryMainPage or ExperimentSymbolHistoryVersionsPage is active, data is now always read from symbol_history instead of a JOIN on package_symbols and documentation_symbols. For golang/go#37102 Change-Id: I8ca0aece399217b804a9a6c55bbfec5efe5b3a18 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/338450 Trust: Julie Qiu <julie@golang.org> Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-07-21internal/{database,postgres}: export CollectStringsJonathan Amsterdam
Export the CollectStrings function and move to the database package so it can be used elsewhere. Change-Id: I1032e4f5042209e42e8f0de9cebfb48653d56f69 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/336209 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
2021-07-19internal/frontend: do not show symbol history for commandsJulie Qiu
Since symbols don't appear in documentation for commands, also don't show its symbol history. For golang/go#37102 Change-Id: I09ad461ba12b91fc3bb7e6a314f35616e9668ba2 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/333379 Trust: Julie Qiu <julie@golang.org> Run-TryBot: Julie Qiu <julie@golang.org> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2021-07-12internal: support std@dev.fuzzJulie Qiu
It is now possible to fetch std@dev.fuzz and view /std@dev.fuzz on the frontend. For golang/go#46910 Change-Id: I2fd7259840ba32ff35ca323d07412988e533ffba Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/330413 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>
2021-06-18many: remove read-imports experimentJonathan Amsterdam
Remove the read-imports experiment and all references to the package_imports table. Change-Id: If926c47e1d01b3ab0f31bb6efb9c2234418fca1b Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/329229 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
2021-06-14internal/postgres: don't touch package_importsJonathan Amsterdam
If the read-imports experiment is on, replace all references to the package_imports table with the imports table: don't write into or read from package_imports. Change-Id: I02631aba574b9938a44b06bce855997606984939 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/327749 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
2021-06-10internal/postgres: read from imports tableJonathan Amsterdam
Read from the imports table instead of package_imports, under an experiment. Change-Id: Id5b61285325f28a168faeb25651839663269feaf Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/326450 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org> Reviewed-by: Julie Qiu <julie@golang.org>
2021-06-07internal/version: drop Version suffix from constantsJulie Qiu
To avoid repetition, the "Version" suffix in version.LatestVersion, version.MainVersion, and version.MasterVersion are dropped. The current version.Latest function is renamed to version.LatestVersion. Change-Id: I649229939223b686dd95a137df4871a899f48aab Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/325390 Trust: Julie Qiu <julie@golang.org> Run-TryBot: Julie Qiu <julie@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-06-07internal: move version constants to internal/versionJulie Qiu
Because the constants for "latest", "master" and "main" were in package internal, we couldn't use them in internal/stdlib due to an import cycle. They are now moved to internal/version to avoid this cycle. Change-Id: I6ebe7c0f50037be2b047c4a25054a0531dcfd3f8 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/325389 Trust: Julie Qiu <julie@golang.org> Run-TryBot: Julie Qiu <julie@golang.org> Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-05-12internal/postgres: ensure good version not later than cookedJonathan Amsterdam
The good latest version of a module should never be later than the cooked latest version. If it is, then pkgsite will show a different version than the go command will download. One way this can happen is if a module retracts all tagged versions, and pseudo-versions were built on top of some of them. For example, initially it could have versions v0.1.0 v0.1.0-DATE-HASH (a pseudo-version) Then v0.1.0 is retracted and a new pseudo-version appears at head: v0.1.0 (retracted) v0.1.0-DATE-HASH v0.0.0-DATE-HASH (head of default branch) The go command will get the v0.0.0 version, but technically the v0.1.0 is later. For golang/go#43265 Change-Id: I8ff30de4eb2dcdf108205de99af93d2f31772cff Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/318069 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
2021-05-06internal/postgres: delete Legacy functionsJulie Qiu
For golang/go#37102 Change-Id: Icda2856dd6af29267affd075a95974a3c65c0adc Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/317429 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>
2021-05-06internal/postgres: use moduleID in getPackagesInUnitjunjunjunk
Add argument moduleID to getPackagesInUnit for more efficiency. Fixes golang/go#45854 Change-Id: Ib8c7721ae5991704c28f966c6750f17289442dc8 GitHub-Last-Rev: 4986eff55818bfacfeddcc8300d563aa12594187 GitHub-Pull-Request: golang/pkgsite#27 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/315489 Reviewed-by: Jonathan Amsterdam <jba@google.com> Reviewed-by: Julie Qiu <julie@golang.org> Trust: Julie Qiu <julie@golang.org> Run-TryBot: Julie Qiu <julie@golang.org>
2021-05-05internal/postgres: export GetSymbolHistoryForBuildContext and GetPathIDJulie Qiu
GetSymbolHistoryForBuildContext and GetPathID are exported for use in test scripts. Change-Id: Ibb31e22d2a99b9a7c2be8b728f2038cf363d8a30 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/317189 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>
2021-05-05internal: enable symbol history for stdlibJulie Qiu
Symbol history for standard library packages are now always displayed. For golang/go#37102 Change-Id: I323c7735726a22d4caac39bebd2e8d912fd03aad Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/317013 Trust: Julie Qiu <julie@golang.org> Run-TryBot: Julie Qiu <julie@golang.org> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2021-05-05internal/postgres: only fetch symbol history for packagesJulie Qiu
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>
2021-05-04internal: prefix GetSymbolHistory functions with LegacyJulie Qiu
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>
2021-05-04internal/postgres: optimize getSymbolHistoryForBuildContext queryJulie Qiu
getSymbolHistoryForBuildContext now accepts a pathID instead of packagePath as an argument, to avoid a JOIN on the paths table. For golang/go#37102 Change-Id: I4e6ac004eb56f2c7744c2ebd7b0e8dcd995f0f4f Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/316230 Trust: Julie Qiu <julie@golang.org> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2021-05-04internal: change GetSymbolHistoryForBuildContext outputJulie Qiu
GetSymbolHistoryForBuildContext now returns a map for nameToVersion, instead of a full symbol history containing UnitSymbols. This function is only used to output data for the main page, and the other information was not used. For golang/go#37102 Change-Id: I884dbef3b191d3cdc163ec1ab26f86dcf5a2b5ce Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/316190 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>
2021-04-29internal/postgres: read only one doc source from DBJonathan Amsterdam
If GetUnit is passed a build context, it will read documentation source only for that build context. It still reads all the build context values, just only one serialized blob of file ASTs. This sped up getUnitWithAllFields by about 2x on net/http, using detail-stats against the staging DB from a local frontend. Change-Id: Ib8e988940b7f8f8ef2c270129c4338bb3d56b9eb Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/312269 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-04-19internal/frontend: add additional stats in serveUnitPage stackJulie Qiu
Change-Id: I17c9eb093e9e5728477ab0b39c748cc5923d8590 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/311629 Trust: Julie Qiu <julie@golang.org> Run-TryBot: Julie Qiu <julie@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-04-19internal/postgres: add stats for GetUnit and GetUnitMetaJulie Qiu
Additional stats are added to GetUnit and GetUnitMeta to debug latency issues. Change-Id: I07abb3191af2e5802670390029f148fa78863679 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/311429 Trust: Julie Qiu <julie@golang.org> Run-TryBot: Julie Qiu <julie@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-04-16internal: delete unused WithSymbols fieldsetJulie Qiu
Change-Id: I0441003b053a096364d2a1458c69b5ebc81ce375 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/310379 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>
2021-04-13internal: remove unit-meta-with-latest experimentJonathan Amsterdam
For golang/go#43265 Change-Id: I1d056a893fdff60744ff328ab9f4a1b6665b3e32 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/309709 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
2021-04-13many: remove "retractions" experimentJonathan Amsterdam
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>
2021-04-08internal/postgres: continue MustInsertModule cleanupJonathan Amsterdam
Remove calls to MustInsertModuleLMV. It helped to reorganize TestGetLatestUnitVersion to be clearer about the go.mod contents of the various module versions. Change-Id: I7fa41bd742cf8bba2b5274172ad5b79fc22e73a9 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/308270 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-04-08internal/postgres: remove MustInsertModule from remaining testsJonathan Amsterdam
Change-Id: Ife8d5918c63cfc509696aaa273186752fac0652e Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/308269 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-03-22internal/postgres: add ReInsertLatestVersionJonathan Amsterdam
New latest-version info can retract the current latest good version, resulting in an older version becoming the new latest good version. Add a function that updates the search_documents table when that happens. A later CL will also update imports_unique, and will call this function from the worker. For golang/go#44710 Change-Id: I09569e27d384ed7defb06a4e81facdb96c22caeb Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/303312 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org> Reviewed-by: Julie Qiu <julie@golang.org>
2021-03-15internal/postgres: upsert search with module path and version parametersJonathan Amsterdam
When we upsert a row in search_documents, we know the package, module and version. Use that information to select the information to upsert, instead of finding the latest version with an ORDER BY clause. Besides being unnecessarily inefficient, the ORDER BY is not accurate in the presence of retractions and other adjustments. Change-Id: I49a96add12ede3e909d70b5e55094c1b704a1822 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/301510 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
2021-03-15internal/postgres: remove special treatment of incompatible versionsJonathan Amsterdam
When finding the latest version of a unit, if there are no unretracted compatible versions and we should ignore incompatible versions, don't treat the situation specially. After the loop we'll pick the latest incompatible version anyway. Change-Id: I9a3a698f9ba18308b04f3e2f851ef76650af2755 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/301509 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
2021-03-10internal/postgres: rewrite GetUnitMeta with latest versionsJonathan Amsterdam
Behind an experiment flag, rewrite GetUnitMeta to use latest-version information when available. For golang/go#44710 Change-Id: Ife3dc13e518c3bd28ce13073b0f255265980f0a3 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/300429 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
2021-03-04internal/postgres: add collectStringsJonathan Amsterdam
Factor out a common pattern by adding a function that collects strings from a query. Change-Id: Ia9ba535e0deddc79cb0566548ab82d1df0cd52ff Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/298731 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
2021-03-04internal/postgres: move GetUnitMeta to legacyGetUnitMetaJonathan Amsterdam
Also, add an experiment for an alternative implementation. No behavior change; preparation for using the latest_module_versions table. For golang/go#44710 Change-Id: I9ba4fe5ef0cb1b1f4199aa78fd75222a03f0f7e5 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/298510 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
2021-03-03internal/postgres: use latest versions to populate ModuleInfoJonathan Amsterdam
Replace the use of the raw_latest_versions table with the latest_module_versions table. For golang/go#44710 Change-Id: I69eff3f19d209e45d5a568209087eca9cf13a0f2 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/298232 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
2021-03-01internal: do not display README at /stdJulie Qiu
The README is no longer displayed at pkg.go.dev/std. It is also no longer stored in the database when a std module is fetched. For golang/go#44356 Change-Id: I6b1605389bc3c97694b6ec2b06e28006a38be999 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/296950 Trust: Julie Qiu <julie@golang.org> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2021-02-25internal/postgres: fix GetUnit testsJulie Qiu
Change-Id: I8b15ff46d34fb234d222823bb60f24f08cf09ec8 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/296632 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>