From 530bbf058781e00e588f1457b6ee589a64b74da1 Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Fri, 5 Apr 2024 10:46:09 -0400 Subject: i did thing oh god large commit --- src/db/rest/post/api_post.sql | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/db/rest/post/api_post.sql') diff --git a/src/db/rest/post/api_post.sql b/src/db/rest/post/api_post.sql index 0d60473..b5c42a8 100644 --- a/src/db/rest/post/api_post.sql +++ b/src/db/rest/post/api_post.sql @@ -6,7 +6,9 @@ CREATE VIEW api.post AS p.created, p.modified, COALESCE(c.cc, 0) - AS comment_count + AS comment_count, + COALESCE(l.lc, 0) + AS like_count FROM admin.post p LEFT JOIN ( @@ -20,6 +22,17 @@ CREATE VIEW api.post AS ) c ON p.id = c.post_id + LEFT JOIN ( + SELECT + COUNT(l.id) as lc, + l.post_id + FROM + admin.like l + GROUP BY + l.post_id + ) l + ON + p.id = l.post_id LEFT JOIN admin.user u ON -- cgit v1.2.3-freya