# HG changeset patch # User John "Elwin" Edwards # Date 1389356139 18000 # Node ID d2c3c29ca4f9c380e52baf4eb2a8a165268c5e4d # Parent c045d4dcf88a9c23ace2b2a6a5c0f79268aeaa77 Add a new statistics script that creates SVG plots. diff -r c045d4dcf88a -r d2c3c29ca4f9 lighttpd/conf.d/mime.conf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lighttpd/conf.d/mime.conf Fri Jan 10 07:15:39 2014 -0500 @@ -0,0 +1,78 @@ +####################################################################### +## +## MimeType handling +## ------------------- +## +## http://www.lighttpd.net/documentation/configuration.html#mimetypes +## +## Use the "Content-Type" extended attribute to obtain mime type if +## possible +## +mimetype.use-xattr = "disable" + +## +## mimetype mapping +## +mimetype.assign = ( + ".pdf" => "application/pdf", + ".sig" => "application/pgp-signature", + ".spl" => "application/futuresplash", + ".class" => "application/octet-stream", + ".ps" => "application/postscript", + ".torrent" => "application/x-bittorrent", + ".dvi" => "application/x-dvi", + ".gz" => "application/x-gzip", + ".pac" => "application/x-ns-proxy-autoconfig", + ".swf" => "application/x-shockwave-flash", + ".tar.gz" => "application/x-tgz", + ".tgz" => "application/x-tgz", + ".tar" => "application/x-tar", + ".zip" => "application/zip", + ".mp3" => "audio/mpeg", + ".m3u" => "audio/x-mpegurl", + ".wma" => "audio/x-ms-wma", + ".wax" => "audio/x-ms-wax", + ".ogg" => "application/ogg", + ".wav" => "audio/x-wav", + ".gif" => "image/gif", + ".jpg" => "image/jpeg", + ".jpeg" => "image/jpeg", + ".png" => "image/png", + ".svg" => "image/svg+xml", + ".xbm" => "image/x-xbitmap", + ".xpm" => "image/x-xpixmap", + ".xwd" => "image/x-xwindowdump", + ".css" => "text/css", + ".html" => "text/html", + ".htm" => "text/html", + ".js" => "text/javascript", + ".asc" => "text/plain", + ".c" => "text/plain", + ".cpp" => "text/plain", + ".log" => "text/plain", + ".conf" => "text/plain", + ".text" => "text/plain", + ".txt" => "text/plain", + ".spec" => "text/plain", + ".dtd" => "text/xml", + ".xml" => "text/xml", + ".mpeg" => "video/mpeg", + ".mpg" => "video/mpeg", + ".mov" => "video/quicktime", + ".qt" => "video/quicktime", + ".avi" => "video/x-msvideo", + ".asf" => "video/x-ms-asf", + ".asx" => "video/x-ms-asf", + ".wmv" => "video/x-ms-wmv", + ".bz2" => "application/x-bzip", + ".tbz" => "application/x-bzip-compressed-tar", + ".tar.bz2" => "application/x-bzip-compressed-tar", + ".rpm" => "application/x-rpm", + # make the default mime type application/octet-stream. + "" => "application/octet-stream", + ) + + +# +####################################################################### + diff -r c045d4dcf88a -r d2c3c29ca4f9 py/stats2.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/py/stats2.py Fri Jan 10 07:15:39 2014 -0500 @@ -0,0 +1,147 @@ +#!/usr/bin/python3 + +import psycopg2 +import rlgall +from datetime import datetime + +sitename = "rlgallery.org" +svgpath = rlgall.webdir +timestr = datetime.utcnow().strftime("%Y-%m-%d %H:%M") + +dochead = """ + +""" +stylesheet = """ +""" +framerect = '\n' +barstr = '\n' +xllabel = '{1}\n' +ylabel = '{1}\n' +xlabelf = '{0}\n' +ltitle = '{0}\n' +ctitle = '{0}\n' +rtitle = '{0}\n' +ylabelf = """ + + {0} + + +""" + +def ylimits(x): + ll = [2, 3, 4, 5, 6, 8, 10, 15] + m = 1 + size = 0 + while True: + for i in ll: + if i * m > x: + size = i + lim = i * m + break + if size: + break + else: + m *= 10 + if size in [3, 6]: + if lim == 3: + divs = 3 + else: + divs = 6 + elif size in [4, 8]: + divs = 4 + else: + if lim == 2: + divs = 2 + else: + divs = 5 + return divs, lim + +con = psycopg2.connect("dbname=rlg") +cur = con.cursor() + +for game in rlgall.gamelist: + xlq = "SELECT count(*) FROM {0} WHERE xl = %s;".format(game.uname) + scrq = "SELECT count(*) FROM {0} WHERE score >= %s AND score < %s;".format(game.uname) + xls = range(1, 16) + scoreblocks = range(10) + xlcounts = [] + scorecounts = [] + for xl in xls: + cur.execute(xlq, [xl]) + xlcounts.append(cur.fetchone()[0]) + for sn in scoreblocks: + lscore = sn * 1000 + if sn == 9: + hscore = 32000 + else: + hscore = (sn + 1) * 1000 + cur.execute(scrq, (lscore, hscore)) + scorecounts.append(cur.fetchone()[0]) + xlgraph = open("{0}/xl-{1}.svg".format(svgpath, game.uname), "w") + scoregraph = open("{0}/score-{1}.svg".format(svgpath, game.uname), "w") + xlgraph.write(dochead) + scoregraph.write(dochead) + xlgraph.write(stylesheet.format("0000ff")) + scoregraph.write(stylesheet.format("ffff00")) + xlgraph.write(framerect) + scoregraph.write(framerect) + + xldivs, xlmax = ylimits(max(xlcounts)) + scale = 500 / xlmax + for xl, count in zip(xls, xlcounts): + barx = xl * 50 + 60 + barh = round(scale * count) + bary = 550 - barh + xlgraph.write(barstr.format(30, barh, barx, bary)) + xlgraph.write(xllabel.format(barx + 15, xl)) + for yl in range(xldivs + 1): + labeln = int(xlmax * yl / xldivs) + labelh = 550 + 8 - 500 * yl / xldivs + xlgraph.write(ylabel.format(labelh, labeln)) + + scoredivs, scoremax = ylimits(max(scorecounts)) + scale = 500 / scoremax + for block, count in zip(scoreblocks, scorecounts): + barx = block * 75 + 100 + barh = round(scale * count) + bary = 550 - barh + scoregraph.write(barstr.format(75, barh, barx, bary)) + scoregraph.write(xllabel.format(barx, block * 1000)) + for yl in range(scoredivs + 1): + labeln = int(scoremax * yl / scoredivs) + labelh = 550 + 8 - 500 * yl / scoredivs + scoregraph.write(ylabel.format(labelh, labeln)) + + xlgraph.write(xlabelf.format("Experience level")) + xlgraph.write(ylabelf.format("# of games")) + scoregraph.write(xlabelf.format("Score")) + scoregraph.write(ylabelf.format("# of games")) + xlgraph.write(ltitle.format(sitename)) + xlgraph.write(ctitle.format(game.name)) + xlgraph.write(rtitle.format(timestr)) + scoregraph.write(ltitle.format(sitename)) + scoregraph.write(ctitle.format(game.name)) + scoregraph.write(rtitle.format(timestr)) + xlgraph.write('\n') + xlgraph.close() + scoregraph.write('\n') + scoregraph.close() + +cur.close() +con.close() +exit() diff -r c045d4dcf88a -r d2c3c29ca4f9 web/scoring/index.html --- a/web/scoring/index.html Tue Jan 07 21:57:33 2014 -0500 +++ b/web/scoring/index.html Fri Jan 10 07:15:39 2014 -0500 @@ -14,7 +14,18 @@
  • High Scores
  • Explorers
  • +

    Statistics

    +
    Rogue V3 experience
    +
    Rogue V4 experience
    +
    Rogue V5 experience
    +
    Super-Rogue experience
    +
    Advanced Rogue 5 experience
    +
    Rogue V3 scores
    +
    Rogue V4 scores
    +
    Rogue V5 scores
    +
    Super-Rogue scores
    +
    Advanced Rogue 5 scores
    rlgallery.org Recent Games High Scores
    diff -r c045d4dcf88a -r d2c3c29ca4f9 web/scoring/scores.css --- a/web/scoring/scores.css Tue Jan 07 21:57:33 2014 -0500 +++ b/web/scoring/scores.css Fri Jan 10 07:15:39 2014 -0500 @@ -31,6 +31,10 @@ background-color: #FFE0E0; } +div.graph { + margin: 1em auto; +} + span.shdata { display: table-cell; font-weight: bold;