based.fish/functions/__based_stats.fish
2025-06-03 06:36:13 -05:00

34 lines
839 B
Fish
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

function __based_stats
set -l db ~/.local/share/fish/based/based.db
if not test -f $db
echo "Database not found. Run 'based init' first."
return
end
echo "== Based Stats =="
sqlite3 $db "
SELECT 'Total unique commands:', COUNT(DISTINCT cmd) FROM log;
SELECT 'Total executions:', SUM(counter) FROM log;
"
echo
echo "== Top 10 Commands =="
sqlite3 $db "
SELECT printf('%4d × %s', SUM(counter), cmd)
FROM log
GROUP BY cmd
ORDER BY SUM(counter) DESC, MAX(ts) DESC
LIMIT 10;
"
echo
echo "== Top 5 Paths =="
sqlite3 $db "
SELECT printf('%4d × %s', SUM(counter), path)
FROM log
WHERE path != 'fish_history'
GROUP BY path
ORDER BY SUM(counter) DESC
LIMIT 5;
"
end