#!/bin/sh
# @(#) $Header: makedexplist,v 1.6 98/01/06 17:18:38 leres Exp $ (LBL)
#
# makedexplist - construct the actual dexplist
#
# The file that we run off of is built from a base file, a list of
# the groups people are reading here, and a default for everything else.

##  =()<. @<_PATH_SHELLVARS>@>()=
. /usr/news/etc/innshellvars

n=250
cd $NEWSLIB
rm -f dexplist.old
mv dexplist dexplist.old
(
  echo "# WARNING: This source automatically generated, do not edit."
  echo ''
  cat dexplist.base
  echo ''
  echo "# Top $n groups that people actually read here."
  cat ${MOST_LOGS}/topgroups/* \
    ${MOST_LOGS}/topgroups/topgroupslog \
    ${MOST_LOGS}/topgroups/topgroupslog \
    ${MOST_LOGS}/topgroups/topgroupslog \
    ${MOST_LOGS}/topgroups/topgroupslog.1 \
    ${MOST_LOGS}/topgroups/topgroupslog.1 \
    ${MOST_LOGS}/topgroups/topgroupslog.2 | \
      awk '{t[$2] += $1}; END {for (n in t) printf "%s\t%s\n", t[n], n}' | \
      sort -rn | \
      head -$n | \
      sed -e 's/.*	//' -e 's/$/			x	100/'
  echo ''
  echo '# All other groups.'
  echo 'all			x	25'
  echo 'alt			x	10'
) > dexplist
chmod -w dexplist
