From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 882D320248; Thu, 18 Apr 2019 08:07:36 +0000 (UTC) Date: Thu, 18 Apr 2019 08:07:36 +0000 From: Eric Wong To: meta@public-inbox.org Subject: [PATCH v4] inbox: add `modified' sub Message-ID: <20190418080736.GA24562@dcvr> References: <20190417114358.ab2hsmzo7eeehghs@dcvr> <20190417193506.6gradvjye5jvxeu5@dcvr> <20190418005806.64ceewey2hprujop@dcvr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190418005806.64ceewey2hprujop@dcvr> List-Id: 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. --- OK, this is definitely the version I'll go with... st_mtime of msgmap.sqlite3 isn't right for mirrors with intermittent polling or even if the DB gets rebuilt. lib/PublicInbox/Inbox.pm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm index cde4625..0d28dd0 100644 --- a/lib/PublicInbox/Inbox.pm +++ b/lib/PublicInbox/Inbox.pm @@ -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; -- EW