aboutsummaryrefslogtreecommitdiff
path: root/internal/postgres/unit.go
diff options
context:
space:
mode:
authorEthan Lee <ethanalee@google.com>2025-11-17 10:26:27 -0800
committerEthan Lee <ethanalee@google.com>2025-11-17 11:07:52 -0800
commiteaf237733d265b7045c7c51bd4b3989afeb56e4b (patch)
tree7aeaec98e65a79f508c5100989798e21a7de9c62 /internal/postgres/unit.go
parent9f629f032eecb1ec40a71af95db07c1bf3d82b44 (diff)
downloadgo-x-pkgsite-eaf237733d265b7045c7c51bd4b3989afeb56e4b.tar.xz
Revert "internal/postgres: utilize num_imports column in insert_module"
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>
Diffstat (limited to 'internal/postgres/unit.go')
-rw-r--r--internal/postgres/unit.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/internal/postgres/unit.go b/internal/postgres/unit.go
index dda306ea..33c58401 100644
--- a/internal/postgres/unit.go
+++ b/internal/postgres/unit.go
@@ -474,7 +474,12 @@ func (db *DB) getUnitWithAllFields(ctx context.Context, um *internal.UnitMeta, b
r.contents,
d.synopsis,
d.source,
- u.num_imports,
+ COALESCE((
+ SELECT COUNT(unit_id)
+ FROM imports
+ WHERE unit_id = u.id
+ GROUP BY unit_id
+ ), 0) AS num_imports,
COALESCE((
SELECT imported_by_count
FROM search_documents