]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
www_topics: simplify date column mapping
authorEric Wong <e@80x24.org>
Tue, 23 Jan 2024 22:08:59 +0000 (22:08 +0000)
committerEric Wong <e@80x24.org>
Wed, 24 Jan 2024 01:53:49 +0000 (01:53 +0000)
We can rely on SQLite to map `MAX(ds)' to `ds' rather than
doing it in Perl, reducing the size of our Perl optree at the
(smaller) expense of SQLite bytecode.

lib/PublicInbox/WwwTopics.pm

index ad85a46deed6b337583c4c9c658944ca47e0d8f1..9d2707323729da17f906b0870d2843fbcefb88b4 100644 (file)
@@ -9,7 +9,7 @@ sub add_topic_html ($$) {
        my (undef, $smsg) = @_;
        my $s = ascii_html($smsg->{subject});
        $s = '(no subject)' if $s eq '';
-       $_[0] .= "\n".fmt_ts($smsg->{'MAX(ds)'} // $smsg->{ds}) .
+       $_[0] .= "\n".fmt_ts($smsg->{ds}) .
                qq{ <a\nhref="}.mid_href($smsg->{mid}).qq{/#r">$s</a>};
        my $nr = $smsg->{'COUNT(num)'};
        $_[0] .= " $nr+ messages" if $nr > 1;
@@ -29,7 +29,7 @@ EOS
 
 sub topics_active ($) {
         $_[0]->do_get(<<EOS);
-SELECT ddd,MAX(ds),COUNT(num) FROM over WHERE tid IN
+SELECT ddd,MAX(ds) as ds,COUNT(num) FROM over WHERE tid IN
 (SELECT DISTINCT(tid) FROM over WHERE tid > 0 ORDER BY ts DESC LIMIT 200)
 AND +num > 0
 GROUP BY tid
@@ -43,7 +43,6 @@ sub topics_atom { # GET /$INBOX_NAME/topics_(new|active).atom
        my ($ctx) = @_;
        require PublicInbox::WwwAtomStream;
        my ($hdr, $smsg, $val);
-       $_->{ds} //= $_->{'MAX(ds)'} // 0 for @{$ctx->{msgs}};
        PublicInbox::WwwAtomStream->response($ctx, \&topics_i);
 }