db: build the comments count column

This commit is contained in:
Adhityaa Chandrasekar 2018-09-23 00:47:38 -04:00
parent 988a9fb1a1
commit f54f4d0afd

View File

@ -0,0 +1,10 @@
-- Build the comments count column
UPDATE pages
SET commentCount = subquery.commentCount
FROM (
SELECT COUNT(commentHex) as commentCount
FROM comments
WHERE state = 'approved'
GROUP BY (domain, path)
) as subquery;