From b65338b6438ee4017b8dd343b98a86d1d30afc19 Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 7 Dec 2010 20:46:02 -0800 Subject: [PATCH] script for use on relay host --- xwords4/relay/scripts/showrecent.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 xwords4/relay/scripts/showrecent.sh diff --git a/xwords4/relay/scripts/showrecent.sh b/xwords4/relay/scripts/showrecent.sh new file mode 100755 index 000000000..8cea6ac96 --- /dev/null +++ b/xwords4/relay/scripts/showrecent.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +set -e -u + +LIMIT=10000 + +usage() { + echo "usage: $0 [--limit ]" +} + +while [ $# -gt 0 ]; do + case $1 in + --limit) + LIMIT=$2 + shift + ;; + *) usage + ;; + esac + shift +done + +QUERY="WHERE NOT -NTOTAL = sum_array(nperdevice)" +COLUMNS=" dead, connname,cid,room,pub, lang, ntotal, nperdevice, nsent,ctime,mtimes" +COLUMNS_AS="dead as D,connname,cid,room,pub as P,lang as L,ntotal as n,nperdevice as nper,nsent,ctime,mtimes" + +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