From 0cb00d90d88e1d3891d7eca6456c0fe8a8151d7d Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Thu, 11 Feb 2021 20:41:33 +0100 Subject: [PATCH] Do not count IRC users in MAM stats, better IRC stats with external accounts --- rapport_activite/rapport_activites.sh | 40 ++++++++++++++++++--------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/rapport_activite/rapport_activites.sh b/rapport_activite/rapport_activites.sh index aa27be5..202fa33 100755 --- a/rapport_activite/rapport_activites.sh +++ b/rapport_activite/rapport_activites.sh @@ -34,12 +34,12 @@ main() { echo "" echo "h2. ## XMPP/IRC Bridge (Biboumi) usage:" echo "" - echo "* Total users: $(count_biboumi_users)" - echo "** Active: $(count_biboumi_active_users '1 MONTH')" - echo "** Inactive: $(count_biboumi_inactive_users '1 MONTH')" - echo "* Total messages stored (MAM): $(count_biboumi_archived_messages)" echo "* Total channels active: $(count_biboumi_active_chan)" echo "** through $(count_biboumi_active_servers) IRC server(s)" + echo "* Total users: $(count_biboumi_users)" + echo "** Active: $(count_biboumi_active_users '1 MONTH') (External accounts: $(count_biboumi_active_external_users '1 MONTH'))" + echo "** Inactive: $(count_biboumi_inactive_users '1 MONTH') (External accounts: $(count_biboumi_inactive_external_users '1 MONTH'))" + echo "* Total messages stored (MAM): $(count_biboumi_archived_messages)" } get_hard_quota() { @@ -99,11 +99,10 @@ count_removable_accounts() { } count_archived_messages() { - sudo -Hiu postgres psql biboumi -c "select count(*) from archive where peer not like 'irc%' and username not in ('r.giskard', 'lisa.simpson', 'bart.simpson')" -t | grep -v '^$' | awk '{print $1}' + sudo -Hiu postgres psql ejabberd -c "select count(*) from archive where peer not like 'irc%' and username not in ('r.giskard', 'lisa.simpson', 'bart.simpson')" -t | grep -v '^$' | awk '{print $1}' } count_biboumi_users() { - # Accounts inactive *and* who never read the welcome message. sql="select count(distinct owner_) from muclogline_" @@ -111,7 +110,6 @@ count_biboumi_users() { } count_biboumi_active_users() { - # Accounts inactive *and* who never read the welcome message. since=${1:-'1 MONTH'} sql="select count(distinct owner_) from muclogline_ @@ -120,8 +118,17 @@ count_biboumi_active_users() { sudo -Hiu postgres psql biboumi -c "${sql}" -t | grep -v '^$' | awk '{print $1}' } +count_biboumi_active_external_users() { + since=${1:-'1 MONTH'} + sql="select count(distinct owner_) + from muclogline_ + where muclogline_.owner_ not like '%chapril.org%' + and to_timestamp(date_) > current_timestamp - interval '${since}'" + + sudo -Hiu postgres psql biboumi -c "${sql}" -t | grep -v '^$' | awk '{print $1}' +} + count_biboumi_inactive_users() { - # Accounts inactive *and* who never read the welcome message. since=${1:-'1 MONTH'} sql="select count(distinct owner_) from muclogline_ @@ -130,17 +137,25 @@ count_biboumi_inactive_users() { sudo -Hiu postgres psql biboumi -c "${sql}" -t | grep -v '^$' | awk '{print $1}' } -count_biboumi_archived_messages() { - # Accounts inactive *and* who never read the welcome message. +count_biboumi_inactive_external_users() { since=${1:-'1 MONTH'} - sql="select count(distinct body_) + sql="select count(distinct owner_) + from muclogline_ + where muclogline_.owner_ not like '%chapril.org%' + and to_timestamp(date_) < current_timestamp - interval '${since}'" + + sudo -Hiu postgres psql biboumi -c "${sql}" -t | grep -v '^$' | awk '{print $1}' +} + +count_biboumi_archived_messages() { + since=${1:-'1 MONTH'} + sql="select count(body_) from muclogline_" sudo -Hiu postgres psql biboumi -c "${sql}" -t | grep -v '^$' | awk '{print $1}' } count_biboumi_active_servers() { - # Accounts inactive *and* who never read the welcome message. since=${1:-'1 MONTH'} sql="select count(distinct ircservername_) from muclogline_ @@ -150,7 +165,6 @@ count_biboumi_active_servers() { } count_biboumi_active_chan() { - # Accounts inactive *and* who never read the welcome message. since=${1:-'1 MONTH'} sql="select count(distinct ircchanname_) from muclogline_