]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Feed.pm
www: rework query responses to avoid COUNT in SQLite
[public-inbox.git] / lib / PublicInbox / Feed.pm
index 2f59f8c2939b258d0c028c07a323cbb85380fcfb..ff20d7faaef792fd91ba39d7d9627804a81d794b 100644 (file)
@@ -27,14 +27,13 @@ sub generate {
 sub generate_thread_atom {
        my ($ctx) = @_;
        my $mid = $ctx->{mid};
-       my $res = $ctx->{srch}->get_thread($mid);
-       return _no_thread() unless $res->{total};
+       my $msgs = $ctx->{srch}->get_thread($mid);
+       return _no_thread() unless @$msgs;
 
        my $ibx = $ctx->{-inbox};
        my $html_url = $ibx->base_url($ctx->{env});
        $html_url .= PublicInbox::Hval->new_msgid($mid)->{href};
        $ctx->{-html_url} = $html_url;
-       my $msgs = $res->{msgs};
        PublicInbox::WwwAtomStream->response($ctx, 200, sub {
                while (my $smsg = shift @$msgs) {
                        $ibx->smsg_mime($smsg) and return $smsg;
@@ -114,10 +113,10 @@ sub recent_msgs {
                my $o = $qp ? $qp->{o} : 0;
                $o += 0;
                $o = 0 if $o < 0;
-               my $res = $ibx->recent({ limit => $max, offset => $o });
+               my $msgs = $ibx->recent({ limit => $max, offset => $o });
                my $next = $o + $max;
-               $ctx->{next_page} = "o=$next" if $res->{total} >= $next;
-               return $res->{msgs};
+               $ctx->{next_page} = "o=$next" if scalar(@$msgs) == $max;
+               return $msgs;
        }
 
        my $hex = '[a-f0-9]';