2023-12-14 23:38:44 +01:00
|
|
|
#!/bin/sh
|
|
|
|
# Auto generates stats article.
|
|
|
|
|
|
|
|
echo "making stats"
|
|
|
|
|
|
|
|
FILE_NAME="wiki_stats.md"
|
|
|
|
|
2024-01-12 04:25:07 +01:00
|
|
|
printf "# LRS Wiki Stats\n\nThis is an autogenerated article holding stats about this wiki.\n\n" > $FILE_NAME
|
2023-12-14 23:38:44 +01:00
|
|
|
|
|
|
|
printf -- "- number of articles: " >> $FILE_NAME
|
|
|
|
ls *.md | wc -l >> $FILE_NAME
|
|
|
|
|
2024-01-24 18:11:37 +01:00
|
|
|
printf -- "- number of commits: " >> $FILE_NAME
|
|
|
|
git rev-list --count --all >> $FILE_NAME
|
|
|
|
|
2023-12-14 23:38:44 +01:00
|
|
|
printf -- "- total size of all texts in bytes: " >> $FILE_NAME
|
|
|
|
cat *.md | wc -c >> $FILE_NAME
|
|
|
|
|
2024-03-19 16:01:03 +01:00
|
|
|
printf -- "- total number of lines of article texts: " >> $FILE_NAME
|
|
|
|
cat *.md | wc -l >> $FILE_NAME
|
2023-12-14 23:38:44 +01:00
|
|
|
|
2024-03-19 16:01:03 +01:00
|
|
|
printf -- "- number of script lines: " >> $FILE_NAME
|
|
|
|
cat *.sh | wc -l >> $FILE_NAME
|
2023-12-14 23:38:44 +01:00
|
|
|
|
2024-03-19 16:01:03 +01:00
|
|
|
printf "\nlongest articles:\n\n" >> $FILE_NAME
|
|
|
|
ls -1hSs *.md | head -n 20 | sed "s/ *\([^ ]*\) \+\([^ ]*\)\.md/- [\2](\2.md): \1/g" >> $FILE_NAME
|
|
|
|
printf "\n" >> $FILE_NAME
|
2024-01-07 03:16:15 +01:00
|
|
|
|
2024-03-19 19:51:41 +01:00
|
|
|
printf "top 50 5+ letter words:\n\n" >> $FILE_NAME
|
|
|
|
cat *.md | sed "s/([^ ]\+\.md/ /g" | tr -cs "[:alpha:]" "\n" | \
|
|
|
|
sed -r "/^.{,4}$/d" | tr "A-Z" "a-z" | sort | uniq -c | sort -nr | \
|
2024-03-19 16:01:03 +01:00
|
|
|
head -n 50 | sed "s/ \+\([^ ]*\) \+\([^ ]*\)$/- \2 (\1)/g" >> $FILE_NAME
|
2023-12-14 23:38:44 +01:00
|
|
|
printf "\n" >> $FILE_NAME
|
|
|
|
|
2024-03-19 16:01:03 +01:00
|
|
|
printf "latest changes:\n\n\`\`\`\n" >> $FILE_NAME
|
|
|
|
git log --name-only | head -n 50 | grep "Date:\|.*\.md" | sed "s/\([^ ]*\.md\)/ \1/g" >> $FILE_NAME
|
|
|
|
printf "\`\`\`\n" >> $FILE_NAME
|
|
|
|
|
|
|
|
printf "\nmost wanted pages:\n\n" >> $FILE_NAME
|
2024-03-20 20:23:58 +01:00
|
|
|
|
|
|
|
cat ./*.md | sed -n 's/.*\[.*\](\([^\)\(]*\)).*/\1/p' | sort | uniq -c | sort -nr > tmp.txt
|
|
|
|
|
|
|
|
rm tmp2.txt
|
|
|
|
touch tmp2.txt
|
|
|
|
|
|
|
|
while read -r line; do
|
|
|
|
fname=`echo "$line" | grep -o "[^ ]*\.md" -`
|
|
|
|
|
|
|
|
if ! [ -f $fname ]; then
|
|
|
|
printf -- "- [" >> tmp2.txt
|
|
|
|
printf $fname | sed "s/^\([^ ]*\)\.md/\1](${fname}) (/g" >> tmp2.txt
|
|
|
|
echo $line | sed "s/^ *\([0-9]*\).*$/\1)/g" >> tmp2.txt
|
|
|
|
fi
|
|
|
|
done < tmp.txt
|
|
|
|
|
|
|
|
cat tmp2.txt | head -n 20 >> $FILE_NAME
|
|
|
|
rm tmp.txt tmp2.txt
|
|
|
|
|
|
|
|
printf "\nmost popular and lonely pages:\n\n" >> $FILE_NAME
|
|
|
|
|
|
|
|
rm tmp.txt
|
|
|
|
touch tmp.txt
|
|
|
|
|
|
|
|
for fname in *.md; do
|
|
|
|
count=`grep -F -o "($fname)" *.md | wc -l`
|
|
|
|
echo "$count $fname" >> tmp.txt
|
|
|
|
done
|
|
|
|
|
|
|
|
rm tmp2.txt
|
|
|
|
|
|
|
|
cat tmp.txt | sort -n -r | head -n 30 > tmp2.txt
|
|
|
|
echo "- ..." >> tmp2.txt
|
|
|
|
cat tmp.txt | sort -n -r | tail -n 30 >> tmp2.txt
|
|
|
|
cat tmp2.txt | sed "s/ *\([^ ]*\) \+\([^ ]*\)\.md/- [\2](\2.md) (\1) /g" >> $FILE_NAME
|
|
|
|
|
|
|
|
rm tmp2.txt
|
|
|
|
rm tmp.txt
|
|
|
|
|
2024-03-19 16:01:03 +01:00
|
|
|
printf "\n" >> $FILE_NAME
|