Index: work/feature_poll/pcb-rnd-poll.cgi =================================================================== --- work/feature_poll/pcb-rnd-poll.cgi (revision 1641) +++ work/feature_poll/pcb-rnd-poll.cgi (revision 1642) @@ -38,6 +38,15 @@ I do not need this feature at all ' +# the same table with shorter tests +choices_short='production-user +tester +user +lurker +mainliner +no-need +' + # someone is a tester if choice is < $tester_thrs tester_thrs=2 @@ -177,7 +186,7 @@ fi short=`cat $name/short` long=`cat $name/long` - echo "
" if test -z "$QS_SID" @@ -469,6 +478,137 @@ error "You are not logged in." } +cmd_stats() +{ + local old_ifs n not_found votes tmp + + case "$QS_fmt" + in + html|pie) ;; + "") export QS_fmt="html";; + *) error "Invalid format." + esac + + old_ifs=$IFS + IFS="+" + for n in $QS_features + do + if test -f $root/$n/long + then + tmp="`cat $db/votes/$n`" + votes="$votes +@|$n +$tmp +" + else + not_found="$not_found $n" + echo "|$n|" >&2 + fi + done + IFS=$old_ifs + + if test ! -z "$not_found" + then + error "Features not found: $not_found" + fi + + + case "$QS_fmt" + in + html) + render_html < $root/head.html ;; + pie) + echo "Content-Type: image/png" + echo "";; + esac + + echo "$votes" | awk -F "[|]" -v "choices=$choices" -v "choices_short=$choices_short" -v "qs_features=$QS_features" -v "cgi=$CGI" -v "fmt=$QS_fmt" ' + BEGIN { + HTML=1 + PIE=2 + if (fmt == "pie") + fmt = PIE + else if (fmt == "html") + fmt = HTML + else + exit + levels = split(choices, CHOICES, "[\n]")-1 + split(choices_short, CHOICES_SHORT, "[\n]") + COLOR[0]="#FF0000" + COLOR[1]="#AA0000" + COLOR[2]="#AA5500" + COLOR[3]="#55AA00" + COLOR[4]="#777777" + COLOR[5]="#FFFFFF" + } + + function html_tbl(TBL, divisor, feat ,n,img) + { + print "
" CHOICES_SHORT[n+1] " | " int(TBL[n])/divisor + if (n == 0) + print " | " + } + print " |