Grab just the latest 15 threads for feed

This commit is contained in:
swagg boi 2023-04-24 15:29:08 -04:00
parent 3796846809
commit b15fae5a77
2 changed files with 23 additions and 1 deletions

View file

@ -93,7 +93,7 @@ sub by_page($self) {
} }
sub feed($self) { sub feed($self) {
my $threads = $self->thread->by_page(1); my $threads = $self->thread->feed;
my $rss = XML::RSS->new(version => '2.0'); my $rss = XML::RSS->new(version => '2.0');
my $chan_link = $self->url_for(threads_list => {list_page => 1})->to_abs; my $chan_link = $self->url_for(threads_list => {list_page => 1})->to_abs;

View file

@ -97,4 +97,26 @@ sub flag($self, $thread_id) {
END_SQL END_SQL
} }
sub feed($self) {
my $date_format = $self->date_format;
$self->pg->db
->query(<<~'END_SQL', $date_format)->hashes;
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,
t.bump_tally AS bump_tally
FROM threads AS t
LEFT JOIN remarks AS r
ON t.thread_id = r.thread_id
WHERE NOT t.hidden_status
GROUP BY t.thread_id
ORDER BY t.thread_date DESC
LIMIT 15;
END_SQL
}
1; 1;