diff options
| author | Jonathan Amsterdam <jba@google.com> | 2021-06-09 13:49:25 -0400 |
|---|---|---|
| committer | Jonathan Amsterdam <jba@google.com> | 2021-06-10 11:02:10 +0000 |
| commit | fa03708786f2dce02a5ad581e45e997017f72ddf (patch) | |
| tree | ba9e1c2da2b190fd60b2c2205a63554f0fe7eff8 /internal/postgres/unit.go | |
| parent | bcf7e4ea58a11d8c48c6fb54d67ad16987d46b0c (diff) | |
| download | go-x-pkgsite-fa03708786f2dce02a5ad581e45e997017f72ddf.tar.xz | |
internal/postgres: read from imports table
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>
Diffstat (limited to 'internal/postgres/unit.go')
| -rw-r--r-- | internal/postgres/unit.go | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/internal/postgres/unit.go b/internal/postgres/unit.go index 7c7e9c66..b2528f48 100644 --- a/internal/postgres/unit.go +++ b/internal/postgres/unit.go @@ -316,10 +316,17 @@ func (db *DB) getUnitID(ctx context.Context, fullPath, modulePath, resolvedVersi func (db *DB) getImports(ctx context.Context, unitID int) (_ []string, err error) { defer derrors.WrapStack(&err, "getImports(ctx, %d)", unitID) defer middleware.ElapsedStat(ctx, "getImports")() - return collectStrings(ctx, db.db, ` + query := ` SELECT to_path FROM package_imports - WHERE unit_id = $1`, unitID) + WHERE unit_id = $1` + if experiment.IsActive(ctx, internal.ExperimentReadImports) { + query = ` + SELECT p.path + FROM paths p INNER JOIN imports i ON p.id = i.to_path_id + WHERE i.unit_id = $1` + } + return collectStrings(ctx, db.db, query, unitID) } // getPackagesInUnit returns all of the packages in a unit from a |
