about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-04-07 03:41:47 +0000
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-04-07 03:42:20 +0000
commit6f4fcc32237e46fb219df9ad4e92aeb3a170d03f (patch)
treefd4473799e267f7e4b0f2eda05657f5b99b6c78a /lib
parentaed636420b2fee7ff217bfae148cc9485b011d79 (diff)
downloadpublic-inbox-6f4fcc32237e46fb219df9ad4e92aeb3a170d03f.tar.gz
We only need to call get_thread beyond 1000 messages for
fetching entire mboxes.  It's probably too much for the HTML
display otherwise.
Diffstat (limited to 'lib')
-rw-r--r--lib/PublicInbox/Mbox.pm6
-rw-r--r--lib/PublicInbox/Over.pm18
2 files changed, 14 insertions, 10 deletions
diff --git a/lib/PublicInbox/Mbox.pm b/lib/PublicInbox/Mbox.pm
index 4427ae5d..11b23022 100644
--- a/lib/PublicInbox/Mbox.pm
+++ b/lib/PublicInbox/Mbox.pm
@@ -130,9 +130,9 @@ sub thread_mbox {
         eval { require IO::Compress::Gzip };
         return sub { need_gzip(@_) } if $@;
         my $mid = $ctx->{mid};
-        my $msgs = $srch->get_thread($mid, 0);
+        my $msgs = $srch->get_thread($mid, {});
         return [404, [qw(Content-Type text/plain)], []] if !@$msgs;
-        my $prev = $msgs->[-1]->{num};
+        my $prev = $msgs->[-1];
         my $i = 0;
         my $cb = sub {
                 while (1) {
@@ -142,7 +142,7 @@ sub thread_mbox {
                         # refill result set
                         $msgs = $srch->get_thread($mid, $prev);
                         return unless @$msgs;
-                        $prev = $msgs->[-1]->{num};
+                        $prev = $msgs->[-1];
                         $i = 0;
                 }
         };
diff --git a/lib/PublicInbox/Over.pm b/lib/PublicInbox/Over.pm
index 309e044a..da0f11e5 100644
--- a/lib/PublicInbox/Over.pm
+++ b/lib/PublicInbox/Over.pm
@@ -93,16 +93,20 @@ ORDER BY num ASC LIMIT 1
 SELECT tid,sid FROM over WHERE num = ? LIMIT 1
 
         defined $tid or return nothing; # $sid may be undef
-
-        $prev ||= 0;
-        my $cond = 'FROM over WHERE (tid = ? OR sid = ?) AND num > ?';
-        my $msgs = do_get($self, <<"", {}, $tid, $sid, $prev);
-SELECT * $cond ORDER BY num ASC
+        my $sort_col = 'ds';
+        $num = 0;
+        if ($prev) {
+                $num = $prev->{num} || 0;
+                $sort_col = 'num';
+        }
+        my $cond = '(tid = ? OR sid = ?) AND num > ?';
+        my $msgs = do_get($self, <<"", {}, $tid, $sid, $num);
+SELECT num,ts,ds,ddd FROM over WHERE $cond ORDER BY $sort_col ASC
 
         return $msgs unless wantarray;
 
-        my $nr = $dbh->selectrow_array(<<"", undef, $tid, $sid, $prev);
-SELECT COUNT(num) $cond
+        my $nr = $dbh->selectrow_array(<<"", undef, $tid, $sid, $num);
+SELECT COUNT(num) FROM over WHERE $cond
 
         ($nr, $msgs);
 }