From 0872c5cc08dcaaa7f9c1c27b805b06395774e5ad Mon Sep 17 00:00:00 2001 From: pitchum Date: Wed, 18 Nov 2020 12:52:04 +0100 Subject: [PATCH] Update serviceinfo: Fix the way "active users count" is computed Previously, only users having MAM messages stored where counted. Now we count all users who have established a connexion with the server. --- serviceinfo/update_serviceinfo | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/serviceinfo/update_serviceinfo b/serviceinfo/update_serviceinfo index 17cb77b..0331e6b 100755 --- a/serviceinfo/update_serviceinfo +++ b/serviceinfo/update_serviceinfo @@ -1,7 +1,7 @@ #! /bin/bash TEMPLATE=/srv/xmpp.chapril.org/tools/serviceinfo/template-serviceinfo.json -TARGET_FILE=/srv/serviceinfo.json +TARGET_FILE=/srv/xmpp.chapril.org/experimental/serviceinfo.json main() { cat "${TEMPLATE}" \ @@ -56,11 +56,9 @@ starttime() { user_activity() { days_back=${1:-30} - sql="select count(distinct username) - from archive - where peer not like 'irc%' - and kind = 'chat' - and created_at > current_timestamp - interval '${days_back} days' + sql="select count(distinct l.username) + from last l + where to_timestamp(cast(l.seconds as int)) > current_timestamp - interval '${days_back} days' and username not in ('r.giskard', 'lisa.simpson', 'bart.simpson')" psql -U ejabberd -h localhost ejabberd -c "${sql}" -t | grep -v '^$' | awk '{print $1}'