2010-12-08 05:46:02 +01:00
#!/bin/sh
set -e -u
LIMIT = 10000
usage( ) {
echo " usage: $0 [--limit <n>] "
2011-12-07 03:50:04 +01:00
exit 1
2010-12-08 05:46:02 +01:00
}
while [ $# -gt 0 ] ; do
case $1 in
--limit)
LIMIT = $2
shift
; ;
*) usage
; ;
esac
shift
done
QUERY = "WHERE NOT -NTOTAL = sum_array(nperdevice)"
2011-06-27 15:45:14 +02:00
COLUMNS = " dead, connname,cid,room,pub, lang, ntotal, nperdevice, ack,nsent,ctime,mtimes"
COLUMNS_AS = "dead as D,connname,cid,room,pub as P,lang as L,ntotal as n,nperdevice as nper,ack,nsent,ctime,mtimes"
2010-12-08 05:46:02 +01:00
echo " SELECT $COLUMNS_AS FROM ( SELECT $COLUMNS , unnest(mtimes) FROM games $QUERY ) AS set GROUP BY $COLUMNS ORDER BY max(unnest) DESC LIMIT $LIMIT ; " | psql xwgames