diff options
author | Eric Wong <e@80x24.org> | 2023-11-30 11:40:59 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2023-11-30 21:36:53 +0000 |
commit | f49f741ad77f0829492fe0b019255079a05f1f88 (patch) | |
tree | 39b9e76c3d67365fb5b807c659786d1f839884d7 /lib/PublicInbox/CodeSearch.pm | |
parent | 1136d96554555250cb9b1767a8d64d7271c0d15e (diff) | |
download | public-inbox-f49f741ad77f0829492fe0b019255079a05f1f88.tar.gz |
This will allow WWW to use a combined LeiALE-like thing to reduce git processes.
Diffstat (limited to 'lib/PublicInbox/CodeSearch.pm')
-rw-r--r-- | lib/PublicInbox/CodeSearch.pm | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/lib/PublicInbox/CodeSearch.pm b/lib/PublicInbox/CodeSearch.pm index 60deb2ae..208f7528 100644 --- a/lib/PublicInbox/CodeSearch.pm +++ b/lib/PublicInbox/CodeSearch.pm @@ -209,15 +209,20 @@ sub roots2paths { # for diagnostics \%ret; } -sub root_oids ($$) { +sub docids_of_git_dir ($$) { my ($self, $git_dir) = @_; my @ids = $self->docids_by_postlist('P'.$git_dir); - @ids or warn <<""; -BUG? (non-fatal) `$git_dir' not indexed in $self->{topdir} - warn <<"" if @ids > 1; BUG: (non-fatal) $git_dir indexed multiple times in $self->{topdir} + @ids; +} + +sub root_oids ($$) { + my ($self, $git_dir) = @_; + my @ids = docids_of_git_dir $self, $git_dir or warn <<""; +BUG? (non-fatal) `$git_dir' not indexed in $self->{topdir} + my %ret; for my $docid (@ids) { my @oids = xap_terms('G', $self->xdb, $docid); @@ -242,15 +247,21 @@ sub paths2roots { \%ret; } +sub load_ct { # retry_reopen cb + my ($self, $git_dir) = @_; + my @ids = docids_of_git_dir $self, $git_dir or return; + for (@ids) { + my $doc = $self->get_doc($_) // next; + return int_val($doc, CT); + } +} + sub load_commit_times { # each_cindex callback my ($self, $todo) = @_; # todo = [ [ time, git ], [ time, git ] ...] my (@pending, $rec, $dir, @ids, $doc); while ($rec = shift @$todo) { - @ids = $self->docids_by_postlist('P'.$rec->[1]->{git_dir}); + @ids = docids_of_git_dir $self, $rec->[1]->{git_dir}; if (@ids) { - warn <<EOM if @ids > 1; -W: $rec->[1]->{git_dir} indexed multiple times in $self->{topdir} -EOM for (@ids) { $doc = $self->get_doc($_) // next; $rec->[0] = int_val($doc, CT); |