2 # Copyright (C) 2018 all contributors <meta@public-inbox.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
5 # ad-hoc tool for finding duplicates, unstable!
8 use PublicInbox::Inbox;
10 use PublicInbox::Search;
11 use PublicInbox::Config;
14 if (index($repo, '@') > 0) {
15 $ibx = PublicInbox::Config->new->lookup($repo);
17 $ibx = { mainrepo => $repo, address => 'unnamed@example.com' };
18 $ibx = PublicInbox::Inbox->new($ibx);
20 $ibx = PublicInbox::Config->new->lookup_name($repo);
22 $ibx or die "No inbox";
23 $ibx->search or die "search not available for inbox";
24 my $dbh = $ibx->search->{over_ro}->connect;
25 my $over = PublicInbox::Over->new($dbh->sqlite_db_filename);
29 foreach my $n (@$nums) {
30 my $smsg = $over->get_art($n) or next;
31 print STDERR "$n $smsg->{blob} $smsg->{mid}\n";
32 my $msg = $ibx->msg_by_smsg($smsg) or next;
33 print "From $smsg->{blob}\@$n Thu Jan 1 00:00:00 1970\n";
34 $$msg =~ s/^(>*From )/>$1/gm;
39 my $sth = $dbh->prepare(<<'');
40 SELECT id,num FROM id2num WHERE num > 0 ORDER BY id
44 my ($id, $num, @nums);
46 ($id, $num) = $sth->fetchrow_array;
48 if ($prev_id != $id) {
49 emit(\@nums) if scalar(@nums) > 1;