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
|
||||
->query(<<~'END_SQL', $date_format, $row_count, $offset)->hashes;
|
||||
SELECT thread_id AS id,
|
||||
TO_CHAR(thread_date, ?) AS date,
|
||||
thread_author AS author,
|
||||
thread_title AS title,
|
||||
thread_body AS body
|
||||
FROM threads
|
||||
WHERE NOT hidden_status
|
||||
ORDER BY bump_date DESC
|
||||
SELECT t.thread_id AS id,
|
||||
TO_CHAR(t.thread_date, ?) AS date,
|
||||
t.thread_author AS author,
|
||||
t.thread_title AS title,
|
||||
t.thread_body AS body,
|
||||
COUNT(r.*) AS remark_count
|
||||
FROM threads t
|
||||
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 ?;
|
||||
END_SQL
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<% for my $thread (@$threads) { =%>
|
||||
<article class="thread">
|
||||
<span class="id">
|
||||
<%= link_to "#$thread->{'id'}",
|
||||
<%= link_to "Thread #$thread->{'id'}",
|
||||
thread_page => {thread_id => $thread->{'id'}} %>
|
||||
</span>
|
||||
<h3 class="title"><%= %$thread{'title'} %></h3>
|
||||
|
|
Loading…
Reference in New Issue
Block a user