Skip to content
Snippets Groups Projects
Commit 46b434ec authored by taggart's avatar taggart
Browse files

new script to find top accounts by number of list subscriptions

parent feaa407a
Branches
No related tags found
No related merge requests found
#!/usr/bin/perl -w
# topsubcount - find the addresses with the most subscriptions
# NOTE: this script requires the current user has read access to the db
# Matt Taggart <taggart@riseup.net> 2018-02
$listsql='mysql -N --batch --database=sympa --execute "select user_subscriber,list_subscriber from subscriber_table"';
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(.*)$/;
$address=$1;
$list=$2;
# hash of arrays, key is address, arrays contain list names
push @{ $subcount{$address} }, $list;
}
# sort by number of lists subscribed
foreach $address ( sort { scalar @{ $subcount{$b} } <=> scalar @{ $subcount{$a} } } keys %subcount) {
#foreach $address ( sort keys %subcount) {
print "$address ", scalar @{ $subcount{$address} }, "\n";
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment