Subversion Repositories wimsdev

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 reyssat 1
#! /bin/sh
2
#
3
#	This script sorts modules according to their popularity.
4
#	It can be run whenever you like, if your site has the
5
#	traffic accounting activated.
6
#	However, if your site does not have a very high trafic,
7
#	it is better never to run it, in order to preserve the
8
#	popularity register files coming with the wims distribution
9
#	which are based on the statistics of the popular wims home server.
10
#	
11
 
12
# base directory.
13
WIMS_HOME=`dirname $0`/..
14
cd $WIMS_HOME
15
WIMS_HOME=`pwd`
16
 
17
if [ ! -f log/account/00access.act ]; then
18
 echo Site accounting not available.
19
 exit
20
fi
21
 
22
# bonus for new modules
23
bonus=1500
24
 
25
# start and end date
26
start=`date -d '12 months ago' '+%Y%m%d'`
27
end=`date -d '1 day ago' '+%Y%m%d'`
28
endd=`date -d '1 day ago' '+%j'`
29
endy=`date -d '1 day ago' '+%Y'`
30
endt=`date -d '31 Dec' '+%j'`
31
 
32
cd log/account
33
stated=`ls [A-Z]* tool* contrib* | grep '@'`
34
 
35
rm -f $WIMS_HOME/tmp/pop* >/dev/null 2>&1
36
for m in $stated
37
do
38
 echo $m
39
 mm=`echo $m | sed 's/\.[a-z][a-z]$/.??/g'`
40
 cat $mm 2>/dev/null | sort -n >$WIMS_HOME/tmp/m
41
 access=`awk 'BEGIN {a=0;b=0;};
42
	$1>'$start' && $1<'$end' {a=a+sqrt($2);b++;};
43
	END {print int(50*a)};' $WIMS_HOME/tmp/m`
44
 beg=`awk '{print $1; exit}' $WIMS_HOME/tmp/m`
45
 if [ -z $beg ]; then
46
  access=0
47
  laps=2
48
 else
49
  if [ $beg -lt $start ]; then beg=$start; fi
50
  begd=`date -d $beg '+%j'`
51
  begy=`date -d $beg '+%Y'`
52
  begt=`date -d "31 Dec $begy" '+%j'`
53
  laps=`expr 365 \* \( $endy - $begy \) + \( $endd - $begd \) + $begt - 365 + 1`
54
 fi
55
 pop=`expr \( $access + $bonus \) / $laps`
56
 echo $m:$m $pop >>$WIMS_HOME/tmp/pop1
57
 echo $m:$pop >>$WIMS_HOME/tmp/pop2
58
done
59
 
60
cd $WIMS_HOME
61
tr @ / <tmp/pop1 >tmp/popp
62
tr @ / <tmp/pop2 >tmp/popv
63
sort -n -r -k2 <tmp/popp >tmp/pop1.sorted
64
bin/dicsort tmp/popp
65
bin/dicsort tmp/popv
66
 
67
mv tmp/pop1.sorted public_html/bases/site/lists/popular
68
mv tmp/popp.sorted public_html/bases/site/pop/dic
69
mv tmp/popv.sorted public_html/bases/site/popular
70
rm -f tmp/pop* tmp/m >/dev/null 2>&1
71