user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [PATCH] lei q: trim JSON output
@ 2021-03-20 12:40 Eric Wong
  2021-03-21  8:23 ` [SQUASH] t/lei_xsearch: fix warnings from {docid} removal Eric Wong
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Wong @ 2021-03-20 12:40 UTC (permalink / raw)
  To: meta

Stop showing `docid' since it's not useful with shards.

`bytes' and `lines' are probably noise, but maybe could be
visible in some "fuller" view.
---
 lib/PublicInbox/LeiOverview.pm | 8 ++++++--
 lib/PublicInbox/LeiXSearch.pm  | 3 ++-
 t/lei-import.t                 | 2 +-
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/lib/PublicInbox/LeiOverview.pm b/lib/PublicInbox/LeiOverview.pm
index 521bca50..1ce2a098 100644
--- a/lib/PublicInbox/LeiOverview.pm
+++ b/lib/PublicInbox/LeiOverview.pm
@@ -136,7 +136,10 @@ sub ovv_end {
 sub _unbless_smsg {
 	my ($smsg, $mitem) = @_;
 
-	delete @$smsg{qw(lines bytes num tid)};
+	# TODO: make configurable
+	# 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->{pct} = get_pct($mitem) if $mitem;
@@ -151,7 +154,8 @@ sub _unbless_smsg {
 		$smsg->{substr($f, 0, 1)} = pairs($v);
 	}
 	$smsg->{'s'} = delete $smsg->{subject};
-	scalar { %$smsg }; # unbless
+	my $kw = delete($smsg->{kw});
+	scalar { %$smsg, ($kw && scalar(@$kw) ? (kw => $kw) : ()) }; # unbless
 }
 
 sub ovv_atexit_child {
diff --git a/lib/PublicInbox/LeiXSearch.pm b/lib/PublicInbox/LeiXSearch.pm
index 57717b87..17171a7f 100644
--- a/lib/PublicInbox/LeiXSearch.pm
+++ b/lib/PublicInbox/LeiXSearch.pm
@@ -70,6 +70,8 @@ sub mitem_kw ($$;$) {
 	my ($smsg, $mitem, $flagged) = @_;
 	my $kw = xap_terms('K', $mitem->get_document);
 	$kw->{flagged} = 1 if $flagged;
+	# we keep the empty array here to prevent expensive work in
+	# ->xsmsg_vmd, _unbless_smsg will clobber it iff it's empty
 	$smsg->{kw} = [ sort keys %$kw ];
 }
 
@@ -85,7 +87,6 @@ sub smsg_for {
 	my $smsg = $ibx->over->get_art($num);
 	return if $smsg->{bytes} == 0;
 	mitem_kw($smsg, $mitem) if $ibx->can('msg_keywords');
-	$smsg->{docid} = $docid;
 	$smsg;
 }
 
diff --git a/t/lei-import.t b/t/lei-import.t
index edb0cd20..e0b517f4 100644
--- a/t/lei-import.t
+++ b/t/lei-import.t
@@ -48,7 +48,7 @@ lei_ok([qw(import --no-kw -F eml -)], undef, $opt,
 lei(qw(q m:v@y));
 $res = json_utf8->decode($lei_out);
 is($res->[1], undef, 'only one result');
-is_deeply($res->[0]->{kw}, [], 'no keywords set');
+is($res->[0]->{kw}, undef, 'no keywords set');
 
 # see t/lei_to_mail.t for "import -F mbox*"
 });

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [SQUASH] t/lei_xsearch: fix warnings from {docid} removal
  2021-03-20 12:40 [PATCH] lei q: trim JSON output Eric Wong
@ 2021-03-21  8:23 ` Eric Wong
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Wong @ 2021-03-21  8:23 UTC (permalink / raw)
  To: meta

Eric Wong <e@80x24.org> wrote:
> Stop showing `docid' since it's not useful with shards.

RTF-test-output :x

---------8<-------
Subject: [PATCH] t/lei_xsearch: fix warnings from {docid} removal

---
 t/lei_xsearch.t | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/t/lei_xsearch.t b/t/lei_xsearch.t
index e56b2820..3eb44233 100644
--- a/t/lei_xsearch.t
+++ b/t/lei_xsearch.t
@@ -3,7 +3,7 @@
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 use strict;
 use v5.10.1;
-use List::Util qw(shuffle max);
+use List::Util qw(shuffle);
 use PublicInbox::TestCommon;
 use PublicInbox::Eml;
 require_mods(qw(DBD::SQLite Search::Xapian));
@@ -62,9 +62,6 @@ is(scalar(@msgs), $nr, 'smsgs retrieved for all');
 
 $mset = $lxs->recent(undef, { limit => 1 });
 is($mset->size, 1, 'one result');
-my $max = max(map { $_->{docid} } @msgs);
-is($lxs->smsg_for(($mset->items)[0])->{docid}, $max,
-	'got highest docid');
 
 my @ibxish = $lxs->locals;
 is(scalar(@ibxish), scalar(@ibx) + 1, 'got locals back');

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-03-21  8:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-20 12:40 [PATCH] lei q: trim JSON output Eric Wong
2021-03-21  8:23 ` [SQUASH] t/lei_xsearch: fix warnings from {docid} removal Eric Wong

user/dev discussion of public-inbox itself

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/meta
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 meta meta/ https://public-inbox.org/meta \
		meta@public-inbox.org
	public-inbox-index meta

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta
	nntp://ou63pmih66umazou.onion/inbox.comp.mail.public-inbox.meta
	nntp://czquwvybam4bgbro.onion/inbox.comp.mail.public-inbox.meta
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.mail.public-inbox.meta
	nntp://news.gmane.io/gmane.mail.public-inbox.general
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

	https://80x24.org/public-inbox.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git