Граф коммитов

218 Коммитов

Автор SHA1 Сообщение Дата
Rob Findley 17386b461f all.bash: add a check for abnormal migrations files
This catches the case where a rebase resulted in overlapping sequence
numbers.

Change-Id: I07e0a3729fabbbef895fae079ff70e8862201cd2
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/460456
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27 16:46:37 -04:00
Rob Findley 27bbac7ffe internal/license: refactor into a single license package
This unifies license-related functionality into a new internal/license
package, with the intention of making it easier to understand handling
of licenses. It also makes some type names a little cleaner.

A few minor changes are made along the way (e.g. LicenseInfo ->
Metadata), and tests are added for license matching.

Updates b/131921712
Updates b/131741680

Change-Id: I6a766513e971cea74938fbc60f0220c702e66bcd
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/459926
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27 16:46:37 -04:00
Rob Findley b1146ec49a internal/postgres: add VersionState functionality
Add new IndexVersion and VersionState types, along with functions for
storing, updating, and retrieving them from postgres.

Updates b/131614050

Change-Id: Ifbc26b061bbdc86c8c727d948f7b4f075d405cb2
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/459933
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27 16:46:37 -04:00
Julie Qiu 9e3f698b71 internal/frontend: redirect to details page if search exact path is found
When searching on godoc.org, if an exact path is found, the user will be
redirected to the package page (example:
https://godoc.org/?q=golang.org/x/tools redirects to
https://godoc.org/golang.org/x/tools).

This behavior is now replicated on the discovery site.

Fixes b/131859851

Change-Id: Ie3e51f1857ba88110dcc7e1f7524abbbb3ae5951
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/460701
Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-27 16:46:37 -04:00
Julie Qiu af8378f36b content,internal/frontend: display range for search results
Search results are currently indicated as "<start> of <total>" (such as
"0 of 95").

They are now displayed as <start>-<end> of <total> (such as "1-10 of
95").

Fixes b/131929222
Updates b/131908602

Change-Id: I266d7094a261b8f3674b6e2368c618c4d6a73221
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/460700
Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-27 16:46:37 -04:00
Julie Qiu 92a4e9f414 internal/frontend: sort packages by path in module view
The pages on the module view are now listed in order
of the package path to preserve directory structure.

Fixes b/131859852

Change-Id: I1924fd48c310e981e5659a9a3e5c44bb1e6bde1f
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/459561
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2020-03-27 16:46:37 -04:00
Julie Qiu 2d4943c69c internal/postgres: use materialized view for search
The mvw_search_documents materialized view is now used for search.

postgres.RefreshSearchDocuments is introduced, which will be used
to refresh data in the materialized view in a later CL.

Fixes b/131861129
Fixes b/131859794
Fixes b/131911629
Updates b/131908602

Change-Id: I33209b65b7d00420660bd6dc58b03250c9fc144a
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/459559
Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-27 16:46:37 -04:00
Julie Qiu 43556f513b internal/postgres: optimize search query
The search query has been optimized with the following:

* Using a where clause to filter out tsv_search_tokens
* Inline query to get packages and licenses and join with the versions
  table in a subquery

This reduced a search for 'cloud' from 7934.626 ms to 1746.115 ms.

Updates b/130090305

Change-Id: I6c71800db9055e02474bfe30d4c9d2ee1c4f7e8a
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/457637
Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-27 16:46:37 -04:00
Julie Qiu bde7c6e06d internal/frontend: limit page number links on search page
At the moment, there is no limit on the number of page links on the
search page, which becomes messy when search has a lot of results.

Page numbers are now calculated using pagesToLink, which returns an
integer slice representing page numbers that will displayed. It
optimizes for the current page to be in the middle of that range
(similar to google.com).

Fixes b/131836875
Updates b/131862035

Change-Id: I9dafc35bff2278a4850bbded086a0000b5f76d3d
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/458088
Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-27 16:46:37 -04:00
Julie Qiu 7baa6acd17 migrations: move 000042_add_module_version_state to 000043_add_module_version_state
A bug was introduced in commit cc073d7624cfc3ca6fd8641101a5ffcc6bd1996d, causing
there to be two schema migrations with 000042.

000042_add_module_version_state is renumbered to 000043_add_module_version_state.

Change-Id: Ib25c631d5c8f662c6f8e8aa5c4da6fc395f7298e
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/459560
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2020-03-27 16:46:37 -04:00
Rob Findley 7b219b601f migrations: add a module_version_state table
Add a module_version_state table to implement the ETL state for new
module versions.

Updates b/131614050

Change-Id: I7496b428588b1d4f461c5da7376012e8513d842a
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/456916
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27 16:46:36 -04:00
Julie Qiu c5efebbdbe migrations: create a materialized view for search
The materialized view mvw_search_documents is created to cache data
needed for generating search results. It contains information about the
number of importers for each package, tsvector tokens used to search,
and package metadata.

This table will be used by internal/postgres.Search in a later CL.

Updates b/131861129

Change-Id: Ib021c1e5cdec07f18304ff8ec5f7198419887dd8
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/458701
Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-27 16:46:36 -04:00
Dmitri Shuralyov 9374a2399f all.bash: skip running staticcheck on thirdparty packages
The output is not actionable because thirdparty packages are copied
from an external source, and we can't modify them directly in this
project.

Remove trailing slash from a relative import path "./internal/secrets".
It's more common to not include a trailing slash when specifying import
paths.

Fixes b/131821500

Change-Id: Id7458b1474a4218422035cb15e305e2b2a356b64
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/457840
Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-27 16:46:36 -04:00
Rob Findley e2b43d39a5 internal/middleware: allow arbitrary images in content-security-policy
At least temporarily, relax the content security policy to allow
arbitrary images, since this is currently breaking images in README
rendering.

Updates b/130541353

Change-Id: Ifbdea9c5600851f998553b413916ddab3d7ffd43
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/459719
Reviewed-by: Andrew Bonventre <andybons@google.com>
2020-03-27 16:46:36 -04:00
Andrew Bonventre dd23db4bae content/static,internal/frontend: facelift of templates
This change is the first step in applying proper structure
and styling based on mockups from UX.

The template structure has changed with a single "base" page,
base.html used as the first template parsed when constructing
each page. Other templates have been updated to use this new
structure.

An option has been added to the frontend controller to reload
templates on each request to ease development.

Change-Id: I6856ad3f854249aaf29e46fc6c3e563039ab931d
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/457866
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27 16:46:36 -04:00
Rob Findley cea252c6f0 internal/frontend: fix version link when package suffix is empty
Fixes b/131861819

Change-Id: I415250aafe92de3154828db2aa06abbffdeff157
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/458901
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27 16:46:36 -04:00
Dmitri Shuralyov 060b1d0554 discovery: update dependencies
Update to a newer versions of github.com/golang-migrate/migrate/v4,
cloud.google.com/go, github.com/google/go-cmp, gocloud.dev, and
google.golang.org/genproto modules in order to significantly reduce
the size of the transitive closure of the required modules (from 640
down to 362).

The latest released version of gocloud.dev module is currently v0.13.0,
and does not yet include the change to drop many unnecessary modules
(specifically, see the go.mod/go.sum file diffs in the commit
4a87797b25).
The next release version v0.14.0 of gocloud.dev will include that
improvement, and it's going to come out within a month. We can update
to it then. All tests pass with the new dependency versions.

This reduces the deploy time of ./cmd/frontend (without a module proxy)
from 9-10 minutes to 2-3 minutes. The deploy time can be improved even
further by using a proxy.

Also update to new versions of htmlg and component packages that have
more visible license information.

Change-Id: I12851ac7a3e66f1d66348d83239686375466ea18
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/457839
Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-27 16:46:36 -04:00
Rob Findley e352f3131a internal/middleware: add a ContentSecurityPolicy middleware
Add a ContentSecurityPolicy middleware to the frontend. For now, this
adds just a basic policy; the associated bug will not be closed until we
have finalized the policy.

Updates b/130541353

Change-Id: I6da1724525eacc02ad334a15e09c226f28ba6001
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/457874
Reviewed-by: Andrew Bonventre <andybons@google.com>
2020-03-27 16:46:36 -04:00
Andrew Bonventre 3eaccdb892 cmd/cron: use secrets package for database password
Plus some additional cleanup and updating of instructions.

Fixes b/129370804

Change-Id: If48070db058b8e7156bb0f6ab1c51ce8031c3ad1
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/454607
Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-27 16:46:36 -04:00
Rob Findley 1cbb46aefa internal/fetch: add a header to godoc.go
Change-Id: I1c417e0fe18488897d584914f6b1e725919e3031
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/458039
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2020-03-27 16:46:36 -04:00
Rob Findley 4d9c2f76a4 internal: make presubmit errors louder and fix missing headers
Clearly I've missed a couple warnings from our presubmit, so I'm making
it louder:
 + Use terminal colors to call out errors and warnings.
 + Always run header check on all (known) internal files, so that it
   doesn't go silent after a bad commit is merged.

Change-Id: I88116e1dcb0ed6c15b8c1369cbb37de00bd57efd
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/457641
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27 16:46:36 -04:00
Dmitri Shuralyov aa9a02804f internal/fetch: render initial package documentation
This CL introduces an initial package documentation rendering code
for the discovery website. It performs the rendering during package
processing in the fetch service. There are many minor details left
to tweak, but it has the right general shape.

Also reduce the scope of work done by packages.Load to work on the
extracted module, and not try to pull in its transitive closure of
dependencies from the internet. What's left is to come up with a way
of writing a test for this, so the behavior doesn't regress.

Load Work Sans, Roboto, and Source Code Pro fonts for use on package
documentation page.

Update x/tools module to latest version.

Change-Id: I08fbbea8ef2b964c7b083a6dae3a725d2b7e4b68
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/457636
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27 16:46:36 -04:00
Julie Qiu 0fac968b65 migrations: add indexes and alter collation to optimize sorting and search performance
The following indexes are added:

* idx_semver_sort ON versions (module_path, major DESC, minor DESC, patch DESC, prerelease DESC)
* idx_package_licenses ON package_licenses(version, module_path, file_path)
* idx_imports_to_path ON imports(to_path, from_path)

The following columns are altered to TYPE TEXT COLLATE "C", since they are used for sorting

* documents.module_path
* documents.package_path
* documents.series_path
* licenses.file_path
* licenses.module_path
* licenses.module_path
* package_licenses.module_path
* package_licenses.package_path

The primary key for imports is ordered to (to_path, from_path, from_version) to improve
performance for aggregating importedby count.

Fixes b/129600165
Updates b/130090305

Change-Id: Ia158884e5eaab1e5b49a651af38a5439b961052e
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/457638
Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-27 16:46:36 -04:00
Rob Findley e3b62934aa internal, internal/fetch: update license parameters
Updates b/131741680

Change-Id: I94928c7a7634fcefea8d4780e32f7ec486751de5
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/457639
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27 16:46:36 -04:00
Rob Findley 44d919e98f internal/fetch: add missing copyright header to license files
Change-Id: I63c187fa24d359ac91c9c8e064bd6ef1694b620c
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/457640
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27 16:46:36 -04:00
Rob Findley 9e140ea2cc internal/postgres: recreate test database on migration failure
If switching between branches with different migrations, it's likely
that migration.Up will fail on your test databases. This can be a pain
now that there are multiple test databases to fix.

To handle this, automate the re-creation of the database if the
migration fails during the Up step.

Also, remove no-longer-needed migration for discovery-database-test.

Updates b/130719094

Change-Id: Ibb0550b95c2e7a3e437402cfe21ea22e460ac27b
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/457036
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27 16:46:36 -04:00
Julie Qiu 184b242475 content,internal/frontend: change default tab, add link for feedback
The default tab is changed to "doc".



The module path is now displayed on the module tab.

Updates b/124309981
Fixes b/131746914

Change-Id: I85957b1b7dd587ad54544e9c269f3f630619a32b
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/457476
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2020-03-27 16:46:36 -04:00
Julie Qiu 67ad226e3f internal/frontend,internal/postgres: fetch documentation
The following queries have been updated to fetch documentation from the
packages table:

* GetPackage
* GetLatestPackage
* GetVersionForPackage

The documentation tab now displays that data.

Fixes b/131706915

Change-Id: I591f374a355c55b8b937dbf2cfb2de6f105591cd
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/456568
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2020-03-27 16:46:36 -04:00
Julie Qiu dc323f1c01 internal: add packages.DocumentationHTML and write to postgres
The string "TODO: <go documentation will go here>" is written to
packages.documentation from the fetch service.

This is an intermediary step to inserting the actual documentation.

Updates b/131706915

Change-Id: Id021e4cc3499f3727bcf561cdc3d23ecfc4a3311
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/456566
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2020-03-27 16:46:36 -04:00
Julie Qiu 9e4ff03038 migrations: recreate vw_licensed_packages view to add documentation column
This CL recreates the view created in
migrations/000023_add_explicit_license_sort.up.sql, to add the package
documentation column.

Updates b/131706915

Change-Id: Iefb300d66ad9d8fbbe9ecbc8e4d38b44008cc77b
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/456567
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2020-03-27 16:46:36 -04:00
Julie Qiu 1819c48b02 internal/postgres: optimize search query
The search query is rewritten to:

* use documents.tsv_search_tokens instead of readme_tokens ||
  synopsis_tokens || name_tokens || path_tokens
* query directly from documents, packages, versions, imports and
  vw_package_licenses instead of using vw_search_results
* filter out results where relevance is < 1e-10 (instead of rank)

Based on my local database, which has 7185 packages, 144 versions and returns
800+ results for the search term "cloud", this reduced search time for "cloud"
from ~2.5secs to less than 300ms.

Updates b/130090305

Change-Id: Ida419e0d349b38149bec0e41db53b8bf0be18710
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/456457
Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-27 16:46:36 -04:00
Rob Findley 58338d760e cmd/cron: fix accidental fmt.Errorf instead of log.Fatalf
Change-Id: Iebc7cae95b4e599a0e264668e364392b125c78ab
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/456234
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27 16:46:36 -04:00
Rob Findley d5be5cee64 internal/fetch: fix license sorting in TestFetchAndInsertVersion
Licenses were being sorted by Type, which need not be unique. Instead,
they should be sorted by FilePath.

Change-Id: I28205a6a0b075d8dd298b31846007009a24d3d18
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/456233
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27 16:46:36 -04:00
Julie Qiu d88ea7bb53 cmd/cron,internal/postgres: retry dropped versions
At the moment, there isn't a way to retry versions that have been
inserted into the version log if they are dropped after the
makeNewVersionsTimeout.

A /retry endpoint is added to the proxy index cron, which gets entries
from the version logs that are not present in the versions table and
have not failed, and retries fetching them.

The fetch service will now write errors to the error log.

This job is a temporary solution for populating the database, while the
go/go-discovery-etl design is being implemented.

Change-Id: I389c537068e05341ac79aac734d6df5766a1f278
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/452776
Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-27 16:46:36 -04:00
Julie Qiu cea7bbca7f migrations: add packages.documentation column
Change-Id: Iecf325408aef16c87d853500299d3fcc5c58d673
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/456997
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2020-03-27 16:46:36 -04:00
Julie Qiu 670f7c1334 migrations: drop versions constraint unique_semver
Fixes b/131595263

Change-Id: Iff82878c041b14892d13e606bb438d27156cdd7d
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/456231
Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-27 16:46:36 -04:00
Rob Findley 089acc7de6 discovery: add handling for non-redistributable packages
This CL implements admittedly complicated logic for handling license
redistributability. It does this in three main steps, which could
conceivably be split into separate CLs if desirable.

1. Add an internal.Package.IsRedistributable method, which reports a
package as redistributable if and only if there is at least one license
permitting redistribution at the module root, and if every directory
containing a detected license file contains at least one license file
permitting redistribution. It is very possible that this logic is will
change in the future.

2. Add behavior in the postgres handler to prune package and version
data that should not be stored for non-redistributable content. As a
precaution it was decided to do this in the data layer rather than at
fetch time.

3. Add handling in the frontend to make it clear when content is not
redistributable.

Because we now have a scenario where we can't show license details, but
still want to surface the license disclaimer, move it to a separate
page.

Also:
 + modify license extraction to store the license path relative to the
   module@version subdirectory of the module zip.
 + fix a bug where VersionType was not set on in postgres.GetPackage.

Fixes b/127335320
Updates b/124309095

Change-Id: I36194b78651ccff91b0e06d0d3d4fc639a884565
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/455069
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27 16:46:36 -04:00
Rob Findley 5b65f2c87d internal/index: add an internal/index package
Add an index.Client, analogous to the existing proxy.Client, that can be
used for fetching VersionLogs from the module index. Move the setup test
helper to index/test_helper.go. This client also implements a new
constraint to require https.

Also switch from reflect.DeepEqual to cmp.Diff for these tests, as it
produces a nice diff out of the box.

Updates b/130540724

Change-Id: I37542c84d8e68347e203e0ebaf81db924fb3b96e
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/456221
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27 16:46:36 -04:00
Dmitri Shuralyov 92a5f006d9 internal/fetch: write an explicit go.mod file when it's missing
Some modules haven't had a go.mod file added to the repository yet.
The go tool uses an implicit module with module path equal to the
import path corresponding to the repository root, and no other
directives.

When trying to process such a module as the main module with the
go/packages library, there needs to be an explicit go.mod file for
go/packages to be able to find where the module is on disk. So,
write the implicit go.mod file explicitly. It's guaranteed not to
exist (since we write it only when it doesn't exist).

Add a test case to TestExtractPackagesFromZip and update some error
messages in it.

Fixes b/130040000

Change-Id: I3eb211aa67b5d87122ce74eaf081f34350e061be
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/456225
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27 16:46:36 -04:00
Dmitri Shuralyov 51faf30dad internal/thirdparty/modfile: add package
Copy the cmd/go/internal/modfile package to internal/thirdparty.
It will be used in following commits to safely operate with go.mod
files.

Commands run to generate this change:

	go run download.go -pkg=modfile
	gofmt -r '"internal/lazyregexp" -> "regexp"' -w ./modfile/rule.go
	gofmt -r 'lazyregexp.New -> regexp.MustCompile' -w ./modfile/rule.go

Change-Id: I44795395bd0dd4411c177b06fdbd95280afbd3a7
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/456224
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27 16:46:36 -04:00
Julie Qiu e8cbd1e772 internal/frontend: update search template to reflect alpha design
The search template has been updated to reflect the discovery site
alpha designs, leading to the following changes:

* SearchPage.NumPage has been added, which indicates the total number of
  pages needed to display all of the search results (given the specified
  limit)
* SearchPage.Total has been renamed to SearchPage.NumResults
* defaultSearchLimit = 10

Templates now support the functions "add" and "iterate".

Updates b/131593473

Change-Id: Ib57a8246199cee81682bb024ce9d317fde07e493
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/455285
Reviewed-by: Andrew Bonventre <andybons@google.com>
2020-03-27 16:46:36 -04:00
Julie Qiu a822bf5a15 content: add footer and update package details nav
The navbar is updated and a footer is added to reflect the discovery
site alpha designs.

Updates b/131593473

Change-Id: I5d2d282e3b5eae6ae76e0d9c1cf216a61714fbe5
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/456216
Reviewed-by: Andrew Bonventre <andybons@google.com>
2020-03-27 16:46:36 -04:00
Julie Qiu 1d0fc472a7 migrations: drop not null on path_tokens and name_tokens
documents.path_tokens and documents.name_tokens will be removed for
tsv_search_tokens. These are set to not null for now while that
implementation is in progress.

Updates b/130090305

Change-Id: Ic95e5592aa0164bd3b5dd9b070fffc64ef2158d9
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/456223
Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-27 16:46:36 -04:00
Rob Findley 53e2ab19f1 all.bash: remove stale comment about test parallelism
Change-Id: I583da888e37d4483faa6d4b463b0bceac6374166
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/456458
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2020-03-27 16:46:36 -04:00
Julie Qiu f2727ed37e internal/frontend: fix malform path error
frontend.HandleDetails now uses module.CheckImportPath to check if the
<import-path> element is valid.

Previously, we were using module.CheckPath, which would fail on any path
ending in v1, such as google.golang.org/api/adexchangebuyer/v1.3.

Change-Id: Ifd5f57bdf9d5d1354def597fdeaa9329eab0f171
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/456219
Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-27 16:46:36 -04:00
Julie Qiu 1445dcf18a content,internal/frontend: update imports, importedby and modules templates
The imports, importedby and module are updated to match the alpha designs.

Imports and ImportedBy now link to the latest version of each package and
display the package name.

A bug is fixed in HandleDetails, where an panic would occur if GetLatestPackage
returned an error and pkg.VersionInfo.Version was accessed immediately after.

Updates b/131593473

Change-Id: Icb42d1752f2d274cccc44cf5d47f994a3eaf2f62
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/455286
Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-27 16:46:36 -04:00
Julie Qiu 2e1a49407d migrations: add documents.tsv_search_tokens
Rather than storing the tsvector data for name, path, synopsis and readme
separately, they will now to be stored together in a tsv_search_tokens,
which has been shown to improve performance for the search query.

Change-Id: I80460b3a9e22efbe642419e37b95e10ed2c73d9f
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/455288
Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-27 16:46:36 -04:00
Julie Qiu f1880ff549 internal/frontend,internal/postgres: display latest package if version is empty
If a user makes a request to /<import-path>, without the <version> query
param, they will now be shown the latest version of the package.

Fixes b/130215822

Change-Id: Ia24c70ad720fd59f8cdf4dc21cded7beeb032bc5
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/456217
Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-27 16:46:36 -04:00
Rob Findley 8f70f0b541 internal/postgres: isolate DB tests to separate databases
This change modifies the postgres test_helper API to make it easier to
use separate databases for each test suite. It also automates the test
database migration, to ensure that tests are run on an up-to-date
database schema.

Updates b/130719094

Change-Id: Iec0c2404b5859f9bb3c403bdec2581b4636f61a6
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/454237
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27 16:46:36 -04:00
Rob Findley 9dd85a464a internal/fetch: move zip-related functions to unzip.go
This is purely moving things around, and contains no code changes.

Change-Id: Ife6f34c849226db05e9131e05201bf1b0d26333a
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/453882
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27 16:46:36 -04:00