commit 623bd05abbfea61310de481b6aa1eae46bb7aa5b
parent 487a751e4d18aecd29cda6996207772252b834c5
Author: Jaromil <jaromil@dyne.org>
Date:   Mon, 18 Jun 2012 15:59:25 +0200
renamed folder to unsorted.ml, better statistics
Diffstat:
4 files changed, 40 insertions(+), 28 deletions(-)
diff --git a/doc/jaromail-manual.org b/doc/jaromail-manual.org
@@ -204,7 +204,7 @@ Jaro Mail and are listed in order of priority:
 | *known*        | Mails whose sender is known (Whitelist)          |
 | *priv*         | Unknown sender, we are the explicit destination  |
 | *unsorted*     | Unknown sender, we are in cc: or somehow reached |
-| *ml.unsorted*  | From a mailinglist that we haven't filtered yet  |
+| *unsorted.ml*  | From a mailinglist that we haven't filtered yet  |
 | *zz.blacklist* | Mails whose sender is not desired (Blacklist)    |
 
 The advantage using such a folder organization is that every time we
@@ -773,7 +773,7 @@ options keep
 
 # Imap folders
 # uncommend to provide a list of folders to be fetched
-# folders INBOX, known, priv, lists, ml.unsorted, unsorted
+# folders INBOX, known, priv, lists, unsorted, unsorted.ml
 #+END_EXAMPLE
 
 *** Accounts/smtp.default
diff --git a/src/stats/visualize/example.js b/src/stats/visualize/example.js
@@ -1,7 +1,5 @@
 // Run the script on DOM ready:
 $(function(){
- $('table').visualize({type: 'pie', height: '300px', width: '420px'});
-	$('table').visualize({type: 'bar', width: '420px'});
-	$('table').visualize({type: 'area', width: '420px'});
-	$('table').visualize({type: 'line', width: '420px'});
+ $('table').visualize({type: 'pie', height: '300px', width: '1024px'});
+	$('table').visualize({type: 'line', width: '1024px'});
 }); 
\ No newline at end of file
diff --git a/src/zlibs/filters b/src/zlibs/filters
@@ -42,7 +42,7 @@ update() {
     maildirmake $MAILDIRS/priv
     maildirmake $MAILDIRS/postponed
     maildirmake $MAILDIRS/unsorted
-    maildirmake $MAILDIRS/ml.unsorted
+    maildirmake $MAILDIRS/unsorted.ml
     ${=mkdir} $MAILDIRS/outbox
 
     ######
@@ -215,16 +215,16 @@ EOF
 * ? test \$PMSRC/pf-save.rc
 { INCLUDERC=\$PMSRC/pf-save.rc }
 
-# if its an unknown mailinglist, save it into ml.unsorted
+# if its an unknown mailinglist, save it into unsorted.ml
 :0
 * ^(List-Id|X-(Mailing-)?List):
-ml.unsorted/
+unsorted.ml/
 
 EOF
 
     # MUTT (generate mailboxes priority this parser)
     echo " \\" >> $MUTTDIR/mboxes
-    echo " +ml.unsorted +unsorted" >> $MUTTDIR/mboxes
+    echo " +unsorted.ml +unsorted" >> $MUTTDIR/mboxes
 
     uniq $MUTTDIR/mboxes > $TMPDIR/mboxes
     mv $TMPDIR/mboxes $MUTTDIR/mboxes
diff --git a/src/zlibs/stats b/src/zlibs/stats
@@ -25,7 +25,7 @@
 
 stats() {
     # make index of all maildirs
-    notice "Maildirs status"
+    notice "Maildirs statistics"
     case ${PARAM[1]} in
 
 	timecloud) timecloud ;;
@@ -34,22 +34,25 @@ stats() {
 
 	*) # simple stats
 	    typeset -alU ml
-	    typeset -al empty
 	    list_maildirs
+	    oldpfx=""
+	    grandtot=0
 	    for i in ${maildirs}; do
-		cur=`ls $MAILDIRS/$i/cur | wc -l`
-		new=`ls $MAILDIRS/$i/cur | wc -l`
-		tot=$(( $cur + $new ))
-		ml+=("$tot\t:: $i\t ($cur/$new)")
+		pfx=`echo $i | cut -d. -f1`
+		if [ "$pfx" = "$oldpfx" ]; then continue
+		else oldpfx=$pfx; fi
+		tot=`find $MAILDIRS/$pfx* -type f | wc -l`
+		{ test $tot -gt 0 } && { 
+		    ml+=("$tot\t:: $pfx")
+		    grandtot=$(( $grandtot + $tot ))
+		}
 	    done
-	    for m in ${ml}; do
-		{ test ${m[1]} = "0" } && { 
-		    empty+=${m}
-		    continue }
+	    for m in ${(O)ml}; do
 		print "    ${m}"
 	    done
-	    { test ${#empty} != 0 } && { emptystr="(${#empty} are empty)" }
-	    notice "Total maildirs: ${#ml} $emptystr"
+	    notice "Total maildirs: ${#ml}"
+	    act "Total e-mails stored: ${grandtot}"
+	    act "Storage occupation: `du -hs $MAILDIRS | awk '{print $1}'`"
 	    ;;
     esac
     return 0
@@ -77,21 +80,22 @@ EOF
     for m in ${maildirs}; do
 	for f in `find $MAILDIRS/${m} -type f`; do
 	    timestamp=`fetchdate "%Y-%U" ${f}`
+	    mdir=`echo $m|cut -d. -f1`
 	    cat <<EOF | ${SQL} -batch $db > $sql
 SELECT * FROM stats
-WHERE ml IS "${m}" AND date IS "${timestamp}";
+WHERE ml IS "${mdir}" AND date IS "${timestamp}";
 EOF
 	    res=`cat $sql`
 	    if [ "$res" = "" ]; then
 		# new tag
 		cat <<EOF | ${SQL} -batch $db
 INSERT INTO stats (date, ml, hits)
-VALUES ("${timestamp}", "${m}", 1);
+VALUES ("${timestamp}", "${mdir}", 1);
 EOF
 	    else
 		cat <<EOF | ${SQL} -batch $db
 UPDATE stats SET hits = hits + 1
-WHERE ml IS "${m}" AND date IS "${timestamp}";
+WHERE ml IS "${mdir}" AND date IS "${timestamp}";
 EOF
 	    fi
 	done
@@ -121,14 +125,24 @@ EOF
 	<tbody>
 
 EOF
+    prevmdir=""
     for m in ${maildirs}; do
-	echo -n "<tr><th scopre=\"row\">$m</th>" >> $table
+	mdir=`echo $m|cut -d. -f1`
+	# skip duplicates
+	if [ "$prevmdir" = "$mdir" ]; then continue
+	else prevmdir=$mdir; fi
+
+	echo -n "<tr><th scopre=\"row\">$mdir</th>" >> $table
 	for w in ${week}; do
 	    cat <<EOF | ${SQL} -batch $db > $sql
 SELECT hits FROM stats
-WHERE ml IS "${m}" AND date IS "${w}";
+WHERE ml IS "${mdir}" AND date IS "${w}";
 EOF
-	echo -n "<td>`cat $sql`</td>" >> $table
+	    sum=0
+	    for h in `cat $sql`; do
+		sum=$(( $sum + $h ))
+	    done
+	    echo -n "<td>$sum</td>" >> $table
 	done
 	echo "</tr>" >> $table
     done