From 9562634a03c57ac7e24167b076a667d75b9f5286 Mon Sep 17 00:00:00 2001 From: Samuel Sloniker Date: Thu, 24 Nov 2022 09:43:04 -0800 Subject: [PATCH] Add stats script --- stats.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 stats.sh diff --git a/stats.sh b/stats.sh new file mode 100755 index 0000000..8cbe0ce --- /dev/null +++ b/stats.sh @@ -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