Skip to content
Snippets Groups Projects
Commit 6cafcb75 authored by taggart's avatar taggart
Browse files

new script to list top lists with addresses in a particular domain

parent 20228c9d
Branches
Tags
No related merge requests found
#!/usr/bin/perl -w
# topdomcount - for a given domain, list the top lists with subscribers in
# that domain
# NOTE: this script requires the current user has read access to the db
# Matt Taggart <taggart@riseup.net> 2019-08
$limit=20;
$count=0;
$listsql='mysql -N --batch --database=sympa --execute "select user_subscriber,list_subscriber from subscriber_table"';
if ( ! $ARGV[0] ) {
print "usage: topdomcount <domain>\n";
exit 1;
}
$target = $ARGV[0];
open(LISTDUMP, "$listsql|") or die "cannot get dump of address+list pairs from database\n";
while (<LISTDUMP>) {
chomp;
# match sane address and list
m/^<?.*\@(.*?)>?\s*\t(.*)$/;
$domain=$1;
$list=$2;
if ( $domain eq $target ) {
# hash, key is list, value is number of subscriber
$domcount{$list}++;
}
}
# sort by number of lists subscribed
foreach $list ( sort { $domcount{$b} <=> $domcount{$a} } keys %domcount) {
$count++;
print "$list ", $domcount{$list}, "\n";
if ( $count == $limit ) {last;}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment