Add stats script

This commit is contained in:
Samuel Sloniker 2022-11-24 09:43:04 -08:00
parent da8c4173c5
commit 9562634a03
Signed by: kj7rrv
GPG Key ID: 1BB4029E66285A62

22
stats.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/bash
total=$(sqlite3 articles.db "SELECT url FROM articles" | wc -l)
left=$(sqlite3 articles.db "SELECT url FROM articles WHERE category = 'left'" | wc -l)
right=$(sqlite3 articles.db "SELECT url FROM articles WHERE category = 'right'" | wc -l)
left_sources=$(sqlite3 articles.db "SELECT source FROM articles WHERE category = 'left'" | sort | uniq)
right_sources=$(sqlite3 articles.db "SELECT source FROM articles WHERE category = 'right'" | sort | uniq)
echo "This model contains a total of $total articles ($left left, $right right)."
echo ""
echo "## Left"
echo ""
for i in $left_sources; do
echo "* $i: $(sqlite3 articles.db "SELECT url FROM articles WHERE source = '$i'" | wc -l)"
done
echo ""
echo "## Right"
echo ""
for i in $right_sources; do
echo "* $i: $(sqlite3 articles.db "SELECT url FROM articles WHERE source = '$i'" | wc -l)"
done