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

145 lines
4.2 KiB
Plaintext
Raw Normal View History

#!/bin/bash
# file: gsl__stats
# Folder: /var/lib/gsl/scripts
2022-06-14 18:51:19 +02:00
# By echolib (XMPP: im@echolib.re)
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
2022-06-14 18:51:19 +02:00
#======================================================================
# Init Stats | Called from Checkers()
#======================================================================
stats__init() {
gsl_stat_po=0;gsl_stat_pc=0 # paragraphs
gsl_stat_bq=0
gsl_stat_abbrs=0
gsl_stat_links=0
gsl_stat_links_online=0
gsl_stat_flinks=0
gsl_stat_images=0
gsl_stat_fcodes=0
gsl_stat_fbruts=0
gsl_stat_strongs=0
gsl_stat_bolds=0
gsl_stat_italics=0
gsl_stat_icodes=0
gsl_stat_strikes=0
gsl_stat_titles=0
}
2022-06-14 18:51:19 +02:00
#======================================================================
# Called from stats ; Counting datas from db
#======================================================================
stats__datas() {
gsl_file_sti="$site_server/$domain_name/www/gsl-sti.properties"
# Basic
stat_authors_max=`cat "$gsl_file_domain_authors" | wc -l`
# Init WWW stats
stat_articles_www=0
stat_articles_pages_www=0
stat_articles_posts_www=0
stat_articles_tags_www=0
stat_articles_words_www=0
stat_articles_quotes_www=0
stat_articles_paragraphs_www=0
stat_articles_links_www=0
stat_articles_links_online_www=0
stat_articles_lists_www=0
stat_articles_lists_items_www=0
stats_articles_max_images_www=0
# Counting Stats
while IFS=: read -r "filename" "status"
do
2022-06-14 18:51:19 +02:00
source "$filename"
! (( $article_Status_www> 0 )) && continue
2022-06-14 18:51:19 +02:00
((stat_articles_www++))
case "$article_Type" in
post) ((stat_articles_posts_www++)) ;;
page) ((stat_articles_pages_www++)) ;;
esac
stat_articles_tags_www=$(( stat_articles_tags_www + stat_Tags ))
stat_articles_words_www=$((stat_articles_words_www + stat_Words ))
stat_articles_quotes_www=$((stat_articles_quotes_www + stat_Quotes ))
stat_articles_paragraphs_www=$((stat_articles_paragraphs_www + stat_Paragraphs ))
stat_articles_links_www=$(( stat_articles_links_www + stat_Links ))
stat_articles_links_online_www=$(( stat_articles_links_online_www + stat_Links_Online ))
stat_articles_lists_www=$(( stat_articles_lists_www + stat_Lists ))
stat_articles_lists_items_www=$(( stat_articles_lists_items_www + stat_Lists_Items ))
stats_articles_max_images_www=$(( stats_articles_max_images_www + stat_max_Images ))
unset ${!article_@}
done < <(grep -H "article_Status_www" "$gsl_dir_db_domain/"*.db)
cat <<EOSTATS > "$gsl_file_sti"
gsl.articles = $stat_articles_www
gsl.articles.pages = $stat_articles_pages_www
gsl.articles.posts = $stat_articles_posts_www
gsl.authors = $stat_authors_max
gsl.articles.tags = $stat_articles_tags_www
gsl.articles.words = $stat_articles_words_www
gsl.articles.quotes = $stat_articles_quotes_www
gsl.articles.paragraphs = $stat_articles_paragraphs_www
gsl.articles.links = $stat_articles_links_www
gsl.articles.links.online = $stat_articles_links_online_www
gsl.articles.lists = $stat_articles_lists_www
gsl.articles.lists.items = $stat_articles_lists_items_www
gsl_articles.images = $stats_articles_max_images_www
EOSTATS
echo "# Statoolinfos: $gsl_file_sti"
exit
}
2022-06-14 18:51:19 +02:00
#======================================================================
# Stat: Count words and misc | Done with check command
# $1: gsl_tmp_èpost
#======================================================================
Stat__words() {
# Global Words
gsl_stat_words=`cat "$1" | wc -w`
gsl_total_images=`grep "_image:" $1 | wc -l`
gsl_total_fcodes=`grep "_code:" $1 | wc -l`
gsl_total_fbruts=`grep "_brut:" $1 | wc -l`
# Lists
(( $gsl_stat_lists > 0 )) \
&& gsl_list_items=`grep "^=\|^+" "$1" | wc -l` \
|| gsl_list_items=0
# Quotes
(( $gsl_stat_bq > 0 )) \
&& gsl_bq_items=`grep "^_year\|^_cite\|_lang\|_book\|_link" "$1" | wc -w` \
|| gsl_bq_items=0
echo "bq items> $gsl_bq_items"
gsl_stat_words=\
$(( gsl_stat_words \
- 2*gsl_stat_p \
- 2*gsl_stat_bq \
- 2*gsl_stat_lists \
- gsl_list_items \
- gsl_bq_items \
- gsl_stat_titles \
- gsl_total_fbrut \
- gsl_total_fcode \
- gsl_total_images \
))
gsl_log_stats=`
printf '%s %s %s\n' \
"W=$gsl_stat_words ; T=$gsl_stat_titles ; P=$gsl_stat_p ;" \
"I=$gsl_total_images ; Q=$gsl_stat_bq ;" \
"L=$gsl_stat_lists ($gsl_list_items)"`
gsl__logs_print -i -st -c \
"$gsl_log_stats" \
"${PWD}/$gsl_post"
}