#!/usr/athena/bin/perl

%mname = ("Jan", 1,
	  "Feb", 2,
	  "Mar", 3,
	  "Apr", 4,
	  "May", 5,
	  "Jun", 6,
	  "Jul", 7,
	  "Aug", 8,
	  "Sep", 9,
	  "Oct", 10,
	  "Nov", 11,
	  "Dec", 12);

@days = (0,0,31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365);

$locklog = "/afs/sipb/project/www/queue/lock-log";

#open(LOG, $locklog);
while(<>){
    split;
    if($_[5]=~/199/){
	$offset=1;
    }
    else{
	$offset=0;
    }

    $who = $_[5+$offset];
    $what = $_[7+$offset];
    $month = $_[1];
    $mon = $mname{$month};
    $day = $_[2];
    $time = $_[3];
    $year = $_[4+$offset];
    $maildate = $_[8+$offset];
    $sender = $_[9+$offset];
    ($mailmon, $mailday) = split("/", $maildate);
    next if $what !~/locked/;
    next if !int($mailday);

    $recvd = ($days[$mailmon])+$mailday;
    $replied = ($days[$mon])+$day;
    $replied += 365 if $mon<$mailmon;
    $responsetime = ($replied-$recvd);
    next if $responsetime > 200;
    $repsonsetime = 0 unless $responsetime >0;
    &param("Said Please", "Didn't Say Please", /please/i);
    &param("MIT Person", "Non-MIT person", $sender=~/mit.edu/i);
    &param($who, "", 1);
}

sub param {
    local($true, $false, $condition)=@_;

    if($condition){
	$wm{$true}+=$responsetime;
	$wmct{$true}++;
    }
    else{
	return unless $false;
	$wm{$false}+=$responsetime;
	$wmct{$false}++;
    }
}

#foreach $s (sort {$senders{$a} <=> $senders{$b};} keys %senders){
#    print("$s: $senders{$s}\n") if $senders{$s} >3;
#}

foreach $wm (keys %wm){
    print("$wm: ".($wm{$wm}/$wmct{$wm})."\n");
}
