gsl-statique-litterateur/var/lib/gsl/scripts/gsl__stats

119 lines
3.1 KiB
Plaintext
Raw Normal View History

#!/bin/bash
# file: gsl__stats
# Folder: /var/lib/gsl/scripts
# By echolib
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
gsl__get_stats() {
gsl_stats_article_all=0 # All non error
# Status
gsl_stats_articles_www=0 # All www
gsl_stats_articles_pages_www=0 # All page www
gsl_stats_articles_posts_www=0 # All page www
gsl_stats_articles_wip=0 # All wip
gsl_stats_articles_pages_wip=0
gsl_stats_articles_posts_wip=0
gsl_stats_articles_chk=0 # All wip
gsl_stats_articles_pages_chk=0
gsl_stats_articles_posts_chk=0
# Author
gsl_auth_max=0
while read -r "N" "AUTHOR"
do
gsl_auth[$N]="$AUTHOR"
gsl_this_auth[$N]=0
((gsl_auth_max++))
done < <(cat -n "$gsl_this_conf_domain/$gsl_filename_auth")
# Counting
while read -r "file_gsl_db"
do
((gsl_stats_article_all++))
gsl_file_uri_db="$gsl_dir_db/$file_gsl_db"
# Author
gsl_auth_name=`grep "Author:" $gsl_file_uri_db | awk -F: '{print $2}'`
for a in `seq 1 $gsl_auth_max`
do
[[ ${gsl_auth[$a]} == "$gsl_auth_name" ]] \
&& ((gsl_this_auth[$a]++))
done
# Online
if [[ `grep "Status:www" $gsl_file_uri_db` ]];then
((gsl_stats_articles_www++))
[[ `grep "page:" $gsl_file_uri_db` ]] \
&& ((gsl_stats_articles_pages_www++))
[[ `grep "post:" $gsl_file_uri_db` ]] \
&& ((gsl_stats_articles_posts_www++))
# WIP
elif [[ `grep "Status:wip" $gsl_file_uri_db` ]];then
((gsl_stats_articles_wip++))
[[ `grep "page:" $gsl_file_uri_db` ]] \
&& ((gsl_stats_articles_pages_wip++))
[[ `grep "post:" $gsl_file_uri_db` ]] \
&& ((gsl_stats_articles_posts_wip++))
# CHK
elif [[ `grep "Status:chk" $gsl_file_uri_db` ]];then
((gsl_stats_articles_chk++))
[[ `grep "page:" $gsl_file_uri_db` ]] \
&& ((gsl_stats_articles_pages_chk++))
[[ `grep "post:" $gsl_file_uri_db` ]] \
&& ((gsl_stats_articles_posts_chk++))
fi
done < <(ls -1 "$gsl_dir_db" | grep ".gsl.db")
# Creating statoolinfos file
#gsl.articles=nombre d'articles
#gsl.articles.pages=nombre d'articles type page
#gsl.articles.posts=nombre d'articles type page
#gsl.authors=nombre d'auteurs
2022-04-25 13:17:09 +02:00
#gsl.articles.words=
#gsl.articles.quotes=
#gsl.articles.paragraphs=
printf '%s\n%s\n%s\n%s\n' \
"gsl.articles=$gsl_stats_articles_www" \
2022-04-25 13:17:09 +02:00
"gsl.articles.pages=$gsl_stats_articles_pages_www" \
"gsl.articles.posts=$gsl_stats_articles_posts_www" \
"gsl.authors=$gsl_auth_max" \
> "$gsl_file_sti" && \
echo "> Génération des stats (Statoolinfos): $gsl_file_sti"
# Show stats
echo -e "# Total (no error): $gsl_stats_article_all"
for a in `seq 1 $gsl_auth_max`
do
echo "- ${gsl_auth[$a]}: ${gsl_this_auth[a]}"
done
echo
printf '%s\n%s%s%s\n%s%s%s\n%s%s%s\n' \
"CHK|WIP|WWW" \
"All: $gsl_stats_articles_chk|" \
"All: $gsl_stats_articles_wip|" \
"All: $gsl_stats_articles_www" \
"Pages: $gsl_stats_articles_pages_chk|" \
"Pages: $gsl_stats_articles_pages_wip|" \
"Pages: $gsl_stats_articles_pages_www" \
"Posts: $gsl_stats_articles_posts_chk|" \
"Posts: $gsl_stats_articles_posts_wip|" \
"Posts: $gsl_stats_articles_posts_wip" \
| column -t -s'|'
}