Make by_page() return the number of remarks
This commit is contained in:
parent
50a512f2ae
commit
3d5a75ffd8
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
@ -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>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user