mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-30 08:34:16 +01:00
improve game query script to filter on connnames and clarify filter param
This commit is contained in:
parent
03efa3a7e6
commit
bba16c481e
1 changed files with 17 additions and 5 deletions
|
@ -2,13 +2,17 @@
|
|||
|
||||
set -e -u
|
||||
|
||||
FILTER=""
|
||||
FILTER_DEVS="1"
|
||||
ROOMS=""
|
||||
CONNNAMES=''
|
||||
|
||||
LIMIT=10000
|
||||
|
||||
usage() {
|
||||
echo "usage: $0 [--limit <n>] [--filter] [--room <room>]*"
|
||||
echo "usage: $0 [--limit <n>] \\"
|
||||
echo " [--no-filter-devices] # default is to show only devices involved in games shown \\"
|
||||
echo " [--room <room>]* # filter on specified room[s] \\"
|
||||
echo " [--connname <connname>]* # filter on specified connname[s]"
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
@ -18,14 +22,19 @@ while [ $# -gt 0 ]; do
|
|||
LIMIT=$2
|
||||
shift
|
||||
;;
|
||||
--filter)
|
||||
FILTER=1
|
||||
--no-filter-devices)
|
||||
FILTER_DEVS=''
|
||||
;;
|
||||
--room)
|
||||
[ -n "$ROOMS" ] && ROOMS="${ROOMS},"
|
||||
ROOMS="$ROOMS '$2'"
|
||||
shift
|
||||
;;
|
||||
--connname)
|
||||
[ -n "$CONNNAMES" ] && CONNNAMES="${CONNNAMES},"
|
||||
CONNNAMES="$CONNNAMES '$2'"
|
||||
shift
|
||||
;;
|
||||
*) usage
|
||||
;;
|
||||
esac
|
||||
|
@ -36,6 +45,9 @@ QUERY="WHERE NOT -NTOTAL = sum_array(nperdevice) AND NOT DEAD"
|
|||
if [ -n "$ROOMS" ]; then
|
||||
QUERY="$QUERY AND room IN ($ROOMS) "
|
||||
fi
|
||||
if [ -n "$CONNNAMES" ]; then
|
||||
QUERY="$QUERY AND connname IN ($CONNNAMES) "
|
||||
fi
|
||||
|
||||
echo -n "Device (pid) count: $(pidof xwords | wc | awk '{print $2}')"
|
||||
echo "; relay pid[s]: $(pidof xwrelay)"
|
||||
|
@ -54,7 +66,7 @@ echo "SELECT * "\
|
|||
|
||||
# Devices
|
||||
LINE="SELECT id, model, osvers, array_length(mtimes, 1) as mcnt, mtimes[1] as mtime, array_length(devTypes, 1) as dcnt, devTypes[1] as dTyp, devids[1] as devid FROM devices "
|
||||
if [ -n "$FILTER" ]; then
|
||||
if [ -n "$FILTER_DEVS" ]; then
|
||||
LINE="${LINE} WHERE id IN (select UNNEST(devids) FROM games $QUERY)"
|
||||
fi
|
||||
LINE="$LINE ORDER BY mtimes[1] DESC LIMIT $LIMIT;"
|
||||
|
|
Loading…
Add table
Reference in a new issue