All about Post Stats

This commit is contained in:
Cyrille L 2022-02-17 17:21:35 +01:00
parent a2c340be3d
commit ea8940a870
7 changed files with 126 additions and 19 deletions

View File

@ -194,6 +194,10 @@ case "$1" in
gsl__check_file "$gsl_dir_helps/gsl_help_write_post" || exit 1 gsl__check_file "$gsl_dir_helps/gsl_help_write_post" || exit 1
cat "$gsl_dir_helps/gsl_help_write_post" cat "$gsl_dir_helps/gsl_help_write_post"
;; ;;
stats)
gsl__check_file "$gsl_dir_helps/gsl_help_stats" || exit 1
cat "$gsl_dir_helps/gsl_help_stats"
;;
esac esac
;; ;;
esac esac

View File

@ -5,6 +5,7 @@ $ gsl [ARG]
help | -h [OPT] : This Help. Add FULL [ARG] for specifics help | -h [OPT] : This Help. Add FULL [ARG] for specifics
install : Show process installation install : Show process installation
write | -w : How to write a Post write | -w : How to write a Post
stats : What are thes numbers in stats DB ?
new | -N : Add and configure a new DOMAIN new | -N : Add and configure a new DOMAIN
@ -19,6 +20,6 @@ $ gsl [ARG]
add : Add author(s) for DOMAIN add : Add author(s) for DOMAIN
remove : Remove author(s) for DOMAIN remove : Remove author(s) for DOMAIN
check | -C [OPT] : Check Posts erors from PWD folder check | -C [OPT] [FILE] : Check Posts erors from PWD folder or [FILE]
-F : Force check again all Posts -F : Force check again

View File

@ -0,0 +1,21 @@
# Stats are one Post per line
Format : txt
Separator : |
# Fields:
1 : Post Filename
2 : Words
3 : Paragraphs
4 : Abbr
5 : Header Links
6 : Header Images
7 : Header Files
8 : Citations
9 : Block-code Files
10 : Posted Links
11 : Italic
12 : Strong
13 : Bold
14 : Inline-Code
15 : Posted files

View File

@ -15,12 +15,25 @@ grep "$gsl_post" \
} }
#======================================================================= #=======================================================================
# Check Post exists and get line NBR in DB # Check Post exists and get line NBR in DB | $1 DB file
#======================================================================= #=======================================================================
gsl__db_post_exists() { gsl__db_post_exists() {
gsl_db_post_exists=`grep -n "$gsl_post" "$1"` case "$1" in
gsl_db_post_line_nbr=`awk -F":" '{print $1}' <<< "$gsl_db_post_exists"` "$gsl_file_db_posts")
gsl_db_post_status=`awk -F"|" '{print $4}' <<< "$gsl_db_post_exists"` gsl_db_post_exists=`
grep -n "$gsl_post" "$1"`
gsl_db_post_line_nbr=`
awk -F":" '{print $1}' <<< "$gsl_db_post_exists"`
gsl_db_post_status=`
awk -F"|" '{print $4}' <<< "$gsl_db_post_exists"`
;;
"$gsl_file_db_stats")
gsl_db_stat_exists=`
grep -n "$gsl_post" "$1"`
gsl_db_stat_line_nbr=`
awk -F":" '{print $1}' <<< "$gsl_db_stat_exists"`
;;
esac
} }
#======================================================================= #=======================================================================
@ -29,7 +42,47 @@ gsl_db_post_status=`awk -F"|" '{print $4}' <<< "$gsl_db_post_exists"`
gsl__db_line_post() { gsl__db_line_post() {
case "$gsl_process" in case "$gsl_process" in
Checked) Checked)
#-------------------------------------------------------------------
# Check if post exists in DB stats.db and get line
#-------------------------------------------------------------------
if ! [[ "$gsl_checker_err" ]];then
gsl_db_stat_line=`
printf '%s%s%s%s%s%s%s%s%s%s\n' \
"$gsl_post|" \
"$gsl_post_stat_w|" \
"$gsl_post_stat_p|" \
"$gsl_post_stat_abbr|" \
"$gsl_post_stat_link|" \
"$gsl_post_stat_image|" \
"$gsl_post_stat_file|" \
"$gsl_post_stat_bq|" \
"$gsl_post_stat_bcode|" \
"${gsl_post_stat_mdb// /|}|"`
gsl__db_post_exists "$gsl_file_db_stats"
if [[ "$gsl_db_stat_line_nbr" ]];then
sed -i "${gsl_db_stat_line_nbr}s/.*/$gsl_db_stat_line/" \
"$gsl_file_db_stats" && \
gsl__logs_print \
"$gsl_log_w" \
"DB" \
"Stat" \
"Line:$gsl_db_stat_line_nbr $gsl_post" \
"$gsl_file_db_stats"
else
echo "$gsl_db_stat_line" >> "$gsl_file_db_stats" && \
gsl__logs_print \
"$gsl_log_w" \
"DB" \
"Stat" \
"Line:NEW $gsl_db_stat_line" \
"$gsl_file_db_stats"
fi
fi
#-------------------------------------------------------------------
# Check if post exists in DB posts.db and get line / status # Check if post exists in DB posts.db and get line / status
#-------------------------------------------------------------------
gsl__db_post_exists "$gsl_file_db_posts" gsl__db_post_exists "$gsl_file_db_posts"
[[ "$gsl_checker_err" ]] && \ [[ "$gsl_checker_err" ]] && \
[[ "$gsl_db_post_line_nbr" ]] \ [[ "$gsl_db_post_line_nbr" ]] \
@ -42,7 +95,7 @@ case "$gsl_process" in
"$gsl_file_db_posts" \ "$gsl_file_db_posts" \
&& return && return
gsl_db_line=` gsl_db_post_line=`
printf '%s%s%s%s%s\n' \ printf '%s%s%s%s%s\n' \
"$gsl_post_type|" \ "$gsl_post_type|" \
"$gsl_post|" \ "$gsl_post|" \
@ -51,7 +104,7 @@ case "$gsl_process" in
"$gsl_process|"` "$gsl_process|"`
if [[ "$gsl_db_post_exists" ]];then if [[ "$gsl_db_post_exists" ]];then
sed -i "${gsl_db_post_line_nbr}s/.*/$gsl_db_line/" \ sed -i "${gsl_db_post_line_nbr}s/.*/$gsl_db_post_line/" \
"$gsl_file_db_posts" && \ "$gsl_file_db_posts" && \
gsl__logs_print \ gsl__logs_print \
"$gsl_log_w" \ "$gsl_log_w" \
@ -62,7 +115,7 @@ case "$gsl_process" in
gsl_checker_war=true gsl_checker_war=true
else else
echo "$gsl_db_line" \ echo "$gsl_db_post_line" \
>> "$gsl_file_db_posts" && \ >> "$gsl_file_db_posts" && \
gsl__logs_print \ gsl__logs_print \
"$gsl_log_i" \ "$gsl_log_i" \

View File

@ -34,6 +34,8 @@ echo -ne "\r\033[2K: Searching for IMAGES..."
gsl__post_check_images gsl__post_check_images
echo -ne "\r\033[2K: Searching for BLOCK-CODES..." echo -ne "\r\033[2K: Searching for BLOCK-CODES..."
gsl__post_check_bcodes gsl__post_check_bcodes
echo -ne "\r\033[2K: Searching for some STATS..."
gsl__post_check_stats
echo -ne "\r\033[2K" echo -ne "\r\033[2K"
@ -284,7 +286,7 @@ do
"$gsl_log_e" \ "$gsl_log_e" \
"Post" \ "Post" \
"${gsl_i_markers[gsl_i]}" \ "${gsl_i_markers[gsl_i]}" \
"Line $gsl_line_nbr: Mismatch ${gsl_u_markers[gsl_i]}" \ "Line:$gsl_line_nbr > Mismatch ${gsl_u_markers[gsl_i]}" \
"${PWD}/$gsl_post" "${PWD}/$gsl_post"
gsl_checker_err=true gsl_checker_err=true
else else
@ -296,6 +298,8 @@ done < <(awk -v line="$gsl_post_begin" \
'NR >= line {print NR":",$0}' \ 'NR >= line {print NR":",$0}' \
"$gsl_post") "$gsl_post")
gsl_post_stat_mdb=${gsl_post_stat_m[@]}
# Show Counts in logs # Show Counts in logs
for gsl_i in `seq 0 $gsl_markers_nbr` for gsl_i in `seq 0 $gsl_markers_nbr`
do do
@ -546,3 +550,16 @@ do
done < <(gsl__get_header "$gsl_marker_image" "$gsl_post") done < <(gsl__get_header "$gsl_marker_image" "$gsl_post")
} }
#=======================================================================
# Check for more STATS
#=======================================================================
gsl__post_check_stats() {
gsl_post_stat_w=`
awk -v l="$gsl_post_begin" \
'NR >= l' \
"$gsl_post" \
| wc -w`
gsl_post_stat_w=$(( $gsl_post_stat_w - 2*$gsl_post_stat_p ))
}

View File

@ -0,0 +1,5 @@
#!/bin/bash
# file: gsl__post_makers
# Folder: /var/lib/gsl/scripts
# By echolib
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007

View File

@ -65,15 +65,21 @@ do
make) make)
gsl_process="Made" gsl_process="Made"
gsl__db_post_exists "$gsl_file_db_posts" gsl__db_post_exists "$gsl_file_db_posts"
if [[ "$gsl_db_post_status" == "Made" ]];then case "$gsl_db_post_status" in
Checked)
true # gsl__post_makers
;;
Made)
gsl__logs_print gsl__logs_print
"$gsl_log_w" \ "$gsl_log_w" \
"Post" \ "Post" \
"Make" \ "Make" \
"$gsl_post already Made (Converted)" \ "$gsl_post already Converted" \
"$gsl_file_db_posts" "$gsl_file_db_posts"
continue continue
fi ;;
esac
;; ;;
esac esac
done done