24
2
Fork 0

Do not count IRC users in MAM stats, better IRC stats with external accounts

This commit is contained in:
Adrien Bourmault 2021-02-11 20:41:33 +01:00 committed by root
parent dd3a70f548
commit 0cb00d90d8
1 changed files with 27 additions and 13 deletions

View File

@ -34,12 +34,12 @@ main() {
echo "" echo ""
echo "h2. ## XMPP/IRC Bridge (Biboumi) usage:" echo "h2. ## XMPP/IRC Bridge (Biboumi) usage:"
echo "" 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 "* Total channels active: $(count_biboumi_active_chan)"
echo "** through $(count_biboumi_active_servers) IRC server(s)" 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() { get_hard_quota() {
@ -99,11 +99,10 @@ count_removable_accounts() {
} }
count_archived_messages() { 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() { count_biboumi_users() {
# Accounts inactive *and* who never read the welcome message.
sql="select count(distinct owner_) sql="select count(distinct owner_)
from muclogline_" from muclogline_"
@ -111,7 +110,6 @@ count_biboumi_users() {
} }
count_biboumi_active_users() { count_biboumi_active_users() {
# Accounts inactive *and* who never read the welcome message.
since=${1:-'1 MONTH'} since=${1:-'1 MONTH'}
sql="select count(distinct owner_) sql="select count(distinct owner_)
from muclogline_ from muclogline_
@ -120,8 +118,17 @@ count_biboumi_active_users() {
sudo -Hiu postgres psql biboumi -c "${sql}" -t | grep -v '^$' | awk '{print $1}' 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() { count_biboumi_inactive_users() {
# Accounts inactive *and* who never read the welcome message.
since=${1:-'1 MONTH'} since=${1:-'1 MONTH'}
sql="select count(distinct owner_) sql="select count(distinct owner_)
from muclogline_ from muclogline_
@ -130,17 +137,25 @@ count_biboumi_inactive_users() {
sudo -Hiu postgres psql biboumi -c "${sql}" -t | grep -v '^$' | awk '{print $1}' sudo -Hiu postgres psql biboumi -c "${sql}" -t | grep -v '^$' | awk '{print $1}'
} }
count_biboumi_archived_messages() { count_biboumi_inactive_external_users() {
# Accounts inactive *and* who never read the welcome message.
since=${1:-'1 MONTH'} 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_" from muclogline_"
sudo -Hiu postgres psql biboumi -c "${sql}" -t | grep -v '^$' | awk '{print $1}' sudo -Hiu postgres psql biboumi -c "${sql}" -t | grep -v '^$' | awk '{print $1}'
} }
count_biboumi_active_servers() { count_biboumi_active_servers() {
# Accounts inactive *and* who never read the welcome message.
since=${1:-'1 MONTH'} since=${1:-'1 MONTH'}
sql="select count(distinct ircservername_) sql="select count(distinct ircservername_)
from muclogline_ from muclogline_
@ -150,7 +165,6 @@ count_biboumi_active_servers() {
} }
count_biboumi_active_chan() { count_biboumi_active_chan() {
# Accounts inactive *and* who never read the welcome message.
since=${1:-'1 MONTH'} since=${1:-'1 MONTH'}
sql="select count(distinct ircchanname_) sql="select count(distinct ircchanname_)
from muclogline_ from muclogline_