From 18db200aea331ad9a7bbf9f81b05bb6b795c6665 Mon Sep 17 00:00:00 2001 From: Thomas Hochstein Date: Sat, 31 May 2025 18:34:41 +0200 Subject: [PATCH] Let dopostingstats default to last month. Signed-off-by: Thomas Hochstein --- contrib/dopostingstats.sh | 15 +++++++++------ doc/ChangeLog | 1 + 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/contrib/dopostingstats.sh b/contrib/dopostingstats.sh index c0e5e8c..61ffd53 100644 --- a/contrib/dopostingstats.sh +++ b/contrib/dopostingstats.sh @@ -1,10 +1,13 @@ #!/bin/bash # installation path is /srv/newsstats/, please adjust accordingly -if [[ $1 =~ [0-9]{4}-[0-9]{2} ]]; then - /srv/newsstats/bin/groupstats.pl --nocomments --sums --format dump --month $1 | /srv/newsstats/bin/postingstats.pl --month $1 | /srv/newsstats/contrib/tinews.pl -X -Y - /srv/newsstats/bin/hoststats.pl --nocomments --sums --format dump --month $1 | /srv/newsstats/bin/postingstats.pl -t server --month $1 | /srv/newsstats/contrib/tinews.pl -X -Y - /srv/newsstats/bin/clientstats.pl --nocomments --sums --versions --format dump --month $1 | /srv/newsstats/bin/postingstats.pl -t client --month $1 | /srv/newsstats/contrib/tinews.pl -X -Y -else - echo 'Input error, please use dopostingstats.sh YYYY-MM' + +# get month +MONTH=$1 +if ! [[ $1 =~ [0-9]{4}-[0-9]{2} ]]; then + MONTH=$(date -d "$(date +%Y-%m-15) -1 month" '+%Y-%m') fi +# post stats +/srv/newsstats/bin/groupstats.pl --nocomments --sums --format dump --month $MONTH | /srv/newsstats/bin/postingstats.pl --month $MONTH | /srv/newsstats/contrib/tinews.pl -X -Y +/srv/newsstats/bin/hoststats.pl --nocomments --sums --format dump --month $MONTH | /srv/newsstats/bin/postingstats.pl -t server --month $MONTH | /srv/newsstats/contrib/tinews.pl -X -Y +/srv/newsstats/bin/clientstats.pl --nocomments --sums --versions --format dump --month $MONTH | /srv/newsstats/bin/postingstats.pl -t client --month $MONTH | /srv/newsstats/contrib/tinews.pl -X -Y diff --git a/doc/ChangeLog b/doc/ChangeLog index 1a442c5..323e178 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -14,6 +14,7 @@ NewsStats 0.4.0 (unreleased) * gatherstats: Remove whitespace from client and version. * Fix version queries. * Add ClientStats to dopostingstats. + * Let dopostingstats default to last month. NewsStats 0.3.0 (2025-05-18) * Extract GroupStats (in gatherstats) to subroutine.