Make by_page() return the number of remarks

This commit is contained in:
swag 2022-09-20 14:20:10 -04:00
parent 50a512f2ae
commit 3d5a75ffd8
2 changed files with 13 additions and 9 deletions

View File

@ -49,14 +49,18 @@ sub by_page($self, $this_page = 1) {
$self->pg->db $self->pg->db
->query(<<~'END_SQL', $date_format, $row_count, $offset)->hashes; ->query(<<~'END_SQL', $date_format, $row_count, $offset)->hashes;
SELECT thread_id AS id, SELECT t.thread_id AS id,
TO_CHAR(thread_date, ?) AS date, TO_CHAR(t.thread_date, ?) AS date,
thread_author AS author, t.thread_author AS author,
thread_title AS title, t.thread_title AS title,
thread_body AS body t.thread_body AS body,
FROM threads COUNT(r.*) AS remark_count
WHERE NOT hidden_status FROM threads t
ORDER BY bump_date DESC LEFT JOIN remarks r
ON t.thread_id = r.thread_id
WHERE NOT t.hidden_status
GROUP BY t.thread_id
ORDER BY t.bump_date DESC
LIMIT ? OFFSET ?; LIMIT ? OFFSET ?;
END_SQL END_SQL
} }

View File

@ -5,7 +5,7 @@
<% for my $thread (@$threads) { =%> <% for my $thread (@$threads) { =%>
<article class="thread"> <article class="thread">
<span class="id"> <span class="id">
<%= link_to "#$thread->{'id'}", <%= link_to "Thread #$thread->{'id'}",
thread_page => {thread_id => $thread->{'id'}} %> thread_page => {thread_id => $thread->{'id'}} %>
</span> </span>
<h3 class="title"><%= %$thread{'title'} %></h3> <h3 class="title"><%= %$thread{'title'} %></h3>