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 4752A1FB0E for ; Tue, 19 Oct 2021 09:33:47 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 10/11] lei inspect: show ISO8601 {rt} and {dt}, too Date: Tue, 19 Oct 2021 09:33:45 +0000 Message-Id: <20211019093346.30885-11-e@80x24.org> In-Reply-To: <20211019093346.30885-1-e@80x24.org> References: <20211019093346.30885-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: While inspect is intended for debugging, the Unix epoch in seconds requires extra steps for human consumption; just steal what we used for "lei q -f json" output. --- lib/PublicInbox/LeiInspect.pm | 5 +++++ lib/PublicInbox/LeiOverview.pm | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/PublicInbox/LeiInspect.pm b/lib/PublicInbox/LeiInspect.pm index 38ef3ad96df2..5ea32ccb7e66 100644 --- a/lib/PublicInbox/LeiInspect.pm +++ b/lib/PublicInbox/LeiInspect.pm @@ -12,10 +12,15 @@ use parent qw(PublicInbox::IPC); use PublicInbox::Config; use PublicInbox::MID qw(mids); use PublicInbox::NetReader qw(imap_uri nntp_uri); +use POSIX qw(strftime); +use PublicInbox::LeiOverview; +*iso8601 = \&PublicInbox::LeiOverview::iso8601; sub _json_prep ($) { my ($smsg) = @_; $smsg->{$_} += 0 for qw(bytes lines); # integerize + $smsg->{dt} = iso8601($smsg->{ds}) if defined($smsg->{ds}); + $smsg->{rt} = iso8601($smsg->{ts}) if defined($smsg->{ts}); +{ %$smsg } # unbless and scalarize } diff --git a/lib/PublicInbox/LeiOverview.pm b/lib/PublicInbox/LeiOverview.pm index 1b9dc9701c95..2d3db9f4ab92 100644 --- a/lib/PublicInbox/LeiOverview.pm +++ b/lib/PublicInbox/LeiOverview.pm @@ -21,7 +21,7 @@ use PublicInbox::LeiToMail; # cf. https://en.wikipedia.org/wiki/JSON_streaming my $JSONL = 'ldjson|ndjson|jsonl'; # 3 names for the same thing -sub _iso8601 ($) { strftime('%Y-%m-%dT%H:%M:%SZ', gmtime($_[0])) } +sub iso8601 ($) { strftime('%Y-%m-%dT%H:%M:%SZ', gmtime($_[0])) } # we open this in the parent process before ->wq_io_do handoff sub ovv_out_lk_init ($) { @@ -139,8 +139,8 @@ sub _unbless_smsg { # num/tid are nonsensical with multi-inbox search, # lines/bytes are not generally useful delete @$smsg{qw(num tid lines bytes)}; - $smsg->{rt} = _iso8601(delete $smsg->{ts}); # JMAP receivedAt - $smsg->{dt} = _iso8601(delete $smsg->{ds}); # JMAP UTCDate + $smsg->{rt} = iso8601(delete $smsg->{ts}); # JMAP receivedAt + $smsg->{dt} = iso8601(delete $smsg->{ds}); # JMAP UTCDate $smsg->{pct} = get_pct($mitem) if $mitem; if (my $r = delete $smsg->{references}) { $smsg->{refs} = [ map { $_ } ($r =~ m/$MID_EXTRACT/go) ];