diff options
| author | Jonathan Amsterdam <jba@google.com> | 2021-02-26 07:45:23 -0500 |
|---|---|---|
| committer | Jonathan Amsterdam <jba@google.com> | 2021-03-02 13:27:35 +0000 |
| commit | bc25b9b76c197ad09fabc6d340ff2e7c27a946a7 (patch) | |
| tree | c828bf2531cf3a08b1353726004aff5c8b6711e2 /internal/postgres/versionstate.go | |
| parent | 41635721a88eb7d4c43b7c71581897aac426d88c (diff) | |
| download | go-x-pkgsite-bc25b9b76c197ad09fabc6d340ff2e7c27a946a7.tar.xz | |
internal/postgres: read/write module_version_states.has_go_mod
Change-Id: I797da3b0199611ac511d7f9460279998be9927ad
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/296811
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
Diffstat (limited to 'internal/postgres/versionstate.go')
| -rw-r--r-- | internal/postgres/versionstate.go | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/internal/postgres/versionstate.go b/internal/postgres/versionstate.go index 279249c2..1667ad4c 100644 --- a/internal/postgres/versionstate.go +++ b/internal/postgres/versionstate.go @@ -47,6 +47,7 @@ type ModuleVersionStateForUpsert struct { AppVersion string Timestamp time.Time Status int + HasGoMod bool GoModPath string FetchErr error PackageVersionStates []*internal.PackageVersionState @@ -100,16 +101,18 @@ func upsertModuleVersionState(ctx context.Context, db *database.DB, numPackages app_version, index_timestamp, status, + has_go_mod, go_mod_path, error, num_packages, incompatible) - VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) + VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11) ON CONFLICT (module_path, version) DO UPDATE SET app_version=excluded.app_version, status=excluded.status, + has_go_mod=excluded.has_go_mod, go_mod_path=excluded.go_mod_path, error=excluded.error, num_packages=excluded.num_packages, @@ -125,7 +128,7 @@ func upsertModuleVersionState(ctx context.Context, db *database.DB, numPackages CURRENT_TIMESTAMP + INTERVAL '1 hour' END;`, mvs.ModulePath, mvs.Version, version.ForSorting(mvs.Version), - mvs.AppVersion, mvs.Timestamp, mvs.Status, mvs.GoModPath, sqlErrorMsg, numPackages, + mvs.AppVersion, mvs.Timestamp, mvs.Status, mvs.HasGoMod, mvs.GoModPath, sqlErrorMsg, numPackages, version.IsIncompatible(mvs.Version)) if err != nil { return err @@ -221,6 +224,7 @@ const moduleVersionStateColumns = ` last_processed_at, next_processed_after, app_version, + has_go_mod, go_mod_path, num_packages` @@ -231,15 +235,20 @@ func scanModuleVersionState(scan func(dest ...interface{}) error) (*internal.Mod v internal.ModuleVersionState lastProcessedAt pq.NullTime numPackages sql.NullInt64 + hasGoMod sql.NullBool ) if err := scan(&v.ModulePath, &v.Version, &v.IndexTimestamp, &v.CreatedAt, &v.Status, &v.Error, - &v.TryCount, &v.LastProcessedAt, &v.NextProcessedAfter, &v.AppVersion, &v.GoModPath, &numPackages); err != nil { + &v.TryCount, &v.LastProcessedAt, &v.NextProcessedAfter, &v.AppVersion, &hasGoMod, &v.GoModPath, + &numPackages); err != nil { return nil, err } if lastProcessedAt.Valid { lp := lastProcessedAt.Time v.LastProcessedAt = &lp } + if hasGoMod.Valid { + v.HasGoMod = hasGoMod.Bool + } if numPackages.Valid { n := int(numPackages.Int64) v.NumPackages = &n |
