Skip to content

Commit

Permalink
Add scan stats report
Browse files Browse the repository at this point in the history
  • Loading branch information
ghostwords committed Sep 30, 2024
1 parent 35ebabb commit feaea4c
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions sql/stats.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit feaea4c

Please sign in to comment.