From feaea4cd74dd93f668df504641461a13bddc21e9 Mon Sep 17 00:00:00 2001 From: Alexei Date: Mon, 30 Sep 2024 17:13:14 -0400 Subject: [PATCH] Add scan stats report --- sql/stats.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 sql/stats.sh diff --git a/sql/stats.sh b/sql/stats.sh new file mode 100755 index 0000000..617cf0c --- /dev/null +++ b/sql/stats.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +sqlite3 badger.sqlite3 -batch "SELECT browser.name, + no_blocking, + num_sites, + COUNT(DISTINCT blocked_trackers.tracker_id) num_blocked, + ((CAST(STRFTIME('%s', end_time) AS INT) - CAST(STRFTIME('%s', start_time) AS INT)) / 60 / 60), + start_time + FROM scan + JOIN browser ON browser.id = scan.browser_id + JOIN (SELECT scan.id AS scan_id, + tr.tracker_id + FROM scan + JOIN browser ON browser.id = scan.browser_id + JOIN tracking tr ON tr.scan_id = scan.id + WHERE scan.daily_scan = 1 + AND scan.start_time > DATETIME('now', '-30 day') + GROUP BY tr.scan_id, tr.tracker_id + HAVING COUNT(DISTINCT tr.site_id) > 2) + AS blocked_trackers ON blocked_trackers.scan_id = scan.id + WHERE scan.daily_scan = 1 + AND scan.start_time > DATETIME('now', '-30 day') + GROUP BY scan_id + ORDER BY scan.start_time DESC" | column -s '|' -t