]> Sergey Matveev's repositories - public-inbox.git/commitdiff
inbox: add `modified' sub
authorEric Wong <e@80x24.org>
Thu, 18 Apr 2019 00:58:06 +0000 (00:58 +0000)
committerEric Wong <e@80x24.org>
Thu, 18 Apr 2019 06:07:24 +0000 (06:07 +0000)
For inboxes with SQLite enabled (all v2, and probably most v1);
we can use the overview DB to get the timestamp of the latest
message.  It's faster than scanning git branches for commit times,
but not always the same.

lib/PublicInbox/Inbox.pm

index cde46258d02d630135f4efb12ba7b3d94178462e..0d28dd04023e95338e456c8ac2f7403f71bcca12 100644 (file)
@@ -333,4 +333,16 @@ sub recent {
        search($self)->{over_ro}->recent($opts, $after, $before);
 }
 
+sub modified {
+       my ($self) = @_;
+       if (my $srch = search($self)) {
+               my $msgs = $srch->{over_ro}->recent({limit => 1});
+               if (my $smsg = $msgs->[0]) {
+                       return $smsg->{ts};
+               }
+               return time;
+       }
+       git($self)->modified; # v1
+}
+
 1;