diff --git a/tools/oldestlists b/tools/oldestlists new file mode 100755 index 0000000000000000000000000000000000000000..5938bd6215f96450a70838bee63b389cb200e2b4 --- /dev/null +++ b/tools/oldestlists @@ -0,0 +1,47 @@ +#!/usr/bin/perl -w +# oldestlists - list the oldest lists +# NOTE: this script requires the current user has read access to the db +# Matt Taggart <taggart@riseup.net> 2019-11 + +use POSIX; + +$num=100; +$i=0; +$expl='/home/sympa/expl'; + +# get a list of all lists in the db +$listsql='mysql -N --batch --database=sympa --execute "select name_list from list_table where status_list = \'open\'"'; + +open(LISTDUMP, "$listsql|") or die "cannot get dump of lists from database\n"; + +while (<LISTDUMP>) { + chomp; + $list=$_; + $dates=`grep date_epoch $expl/$list/config |awk '{print \$2}'`; + + my ($a,$b) = split /\n/, $dates; + # sometimes a config doesn't have a creation date, skip + next if ( $b eq '') ; + # creation date will be older (smaller) + if ( $a > $b ) { + $result{$list}=$b; + } else { + $result{$list}=$a; + } +} + +format Foo = +@<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +$date, $list +. +$~=Foo; +$date='Date'; +$list='List Name'; +write; + +foreach $list ( sort { $result{$a} <=> $result{$b} } keys %result ) { + $i++; + last if ( $i > $num ); + $date = strftime "%Y %b %e", localtime($result{$list}); + write; +}