#!/tools/ns/bin/perl5
#
# $Id: accumulate_stats.pl,v 1.2 1998/05/21 20:40:01 sheneman Exp $
#
##############################################################################
#
# The contents of this file are subject to the Netscape Public License Version
# 1.0 (the "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at http://www.mozilla.org/NPL/ 
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
# the specific language governing rights and limitations under the License. 
#
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are Copyright (C) 1998 Netscape
# Communications Corporation. All Rights Reserved.
#
##############################################################################
#
# accumulate_stats.pl
#
# Collect all stats from the various output files and stick them 
#   in files for records of progress.
#

$PATH      = "/u/sheneman/projects/cleanup/current";
$STAT_PATH = "$PATH/stats";

# the names of the current files
$cat1a_nscp_file      = "$PATH/nscp_expired.txt";
$cat1a_ic_file        = "$PATH/ic_expired.txt";
$cat1a_vendors_file   = "$PATH/vendors_expired.txt";
$cat1a_interim_file   = "$PATH/interim_expired.txt";
$cat1a_oem_file       = "$PATH/oem_expired.txt";
$cat1a_unknown_file   = "$PATH/unknown_expired.txt";

$cat1b_nscp_file      = "$PATH/nscp_two.txt";
$cat1b_ic_file        = "$PATH/ic_two.txt";
$cat1b_vendors_file   = "$PATH/vendors_two.txt";
$cat1b_interim_file   = "$PATH/interim_two.txt";
$cat1b_oem_file       = "$PATH/oem_two.txt";
$cat1b_unknown_file   = "$PATH/unknown_two.txt";

# the names of the current files
$cat2_file       = "$PATH/cat2.txt";

# the names of the current files
$cat3_file       = "$PATH/cat3.txt";

# the names of the current files
$cat5_nscp_file      = "$PATH/nscp_cat5.txt";
$cat5_ic_file        = "$PATH/ic_cat5.txt";
$cat5_vendors_file   = "$PATH/vendors_cat5.txt";
$cat5_interim_file   = "$PATH/interim_cat5.txt";
$cat5_oem_file       = "$PATH/oem_cat5.txt";
$cat5_unknown_file   = "$PATH/unknown_cat5.txt";

# the names of the current files
$cat6_file      = "$PATH/cat6.txt";

# the names of the current files
$cat7_nscp_file      = "$PATH/nscp_cat7.txt";
$cat7_ic_file        = "$PATH/ic_cat7.txt";
$cat7_vendors_file   = "$PATH/vendors_cat7.txt";
$cat7_interim_file   = "$PATH/interim_cat7.txt";
$cat7_oem_file       = "$PATH/oem_cat7.txt";
$cat7_unknown_file   = "$PATH/unknown_cat7.txt";

# the names of the current files
$cat8_file      = "$PATH/cat8.txt";

# the names of the current files
$cat9_nscp_file      = "$PATH/nscp_cat9.txt";
$cat9_ic_file        = "$PATH/ic_cat9.txt";
$cat9_vendors_file   = "$PATH/vendors_cat9.txt";
$cat9_interim_file   = "$PATH/interim_cat9.txt";
$cat9_oem_file       = "$PATH/oem_cat9.txt";
$cat9_unknown_file   = "$PATH/unknown_cat9.txt";


sub do_stat {

    ($infile, $outfile) = @_;

    $datecmd = "date \'+ \%m/\%d/\%y";
    $date = `$datecmd`;
    chop $date;

    $lines = `cat $infile | grep USER | wc -l`;
    chop $lines;

    @intext = `cat $STAT_PATH/$outfile`;

    # do the work here
    open(OUT, "> $STAT_PATH/$outfile");
    print(OUT "$date $lines \texceptions\n");
    foreach $i (@intext) {
	print(OUT "$i");
    }
    close(OUT);

    return 0;
}


# print the total number of exceptions overall
sub do_sum {

    ($outfile) = @_;

    $datecmd = "date \'+ \%m/\%d/\%y";
    $date = `$datecmd`;
    chop $date;

    $lines = `cat $PATH/*.txt | grep USER | wc -l`;
    chop $lines;

    @intext = `cat $STAT_PATH/$outfile`;

    # do the work here
    open(OUT, "> $STAT_PATH/$outfile");
    print(OUT "$date $lines \texceptions\n");
    foreach $i (@intext) {
	print(OUT "$i");
    }
    close(OUT);

    return 0;
}


# do ALL the indexing of the various categories
&do_stat($cat1a_nscp_file,    "cat1a_nscp.txt");
&do_stat($cat1a_vendors_file, "cat1a_vendors.txt");
&do_stat($cat1a_ic_file,      "cat1a_ic.txt");
&do_stat($cat1a_interim_file, "cat1a_interim.txt");
&do_stat($cat1a_oem_file,     "cat1a_oem.txt");
&do_stat($cat1a_unknown_file, "cat1a_unknown.txt");

&do_stat($cat1b_nscp_file,    "cat1b_nscp.txt");
&do_stat($cat1b_vendors_file, "cat1b_vendors.txt");
&do_stat($cat1b_ic_file,      "cat1b_ic.txt");
&do_stat($cat1b_interim_file, "cat1b_interim.txt");
&do_stat($cat1b_oem_file,     "cat1b_oem.txt");
&do_stat($cat1b_unknown_file, "cat1b_unknown.txt");

&do_stat($cat2_file,          "cat2.txt");

&do_stat($cat3_file,          "cat3.txt");

&do_stat($cat5_nscp_file,     "cat5_nscp.txt");
&do_stat($cat5_vendors_file,  "cat5_vendors.txt");
&do_stat($cat5_ic_file,       "cat5_ic.txt");
&do_stat($cat5_interim_file,  "cat5_interim.txt");
&do_stat($cat5_oem_file,      "cat5_oem.txt");
&do_stat($cat5_unknown_file,  "cat5_unknown.txt");

&do_stat($cat6_file,          "cat6.txt");

&do_stat($cat7_nscp_file,     "cat7_nscp.txt");
&do_stat($cat7_vendors_file,  "cat7_vendors.txt");
&do_stat($cat7_ic_file,       "cat7_ic.txt");
&do_stat($cat7_interim_file,  "cat7_interim.txt");
&do_stat($cat7_oem_file,      "cat7_oem.txt");
&do_stat($cat7_unknown_file,  "cat7_unknown.txt");

&do_stat($cat8_file,          "cat8.txt");

&do_stat($cat9_nscp_file,     "cat9_nscp.txt");
&do_stat($cat9_vendors_file,  "cat9_vendors.txt");
&do_stat($cat9_ic_file,       "cat9_ic.txt");
&do_stat($cat9_interim_file,  "cat9_interim.txt");
&do_stat($cat9_oem_file,      "cat9_oem.txt");
&do_stat($cat9_unknown_file,  "cat9_unknown.txt");

# sum all of the stats here
&do_sum("sum.txt");

# whew!!!
exit 0;
















