mirror of
https://github.com/pupperpowell/bibdle.git
synced 2026-02-04 10:54:44 -05:00
32 lines
679 B
Bash
Executable File
32 lines
679 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# analyze_top_users.sh
|
|
# Analyzes the daily_completions table to find the top 10 anonymous IDs by completion count
|
|
|
|
# Set database path from argument or default to dev.db
|
|
DB_PATH="${1:-dev.db}"
|
|
|
|
# Check if database file exists
|
|
if [ ! -f "$DB_PATH" ]; then
|
|
echo "Error: Database file not found: $DB_PATH"
|
|
echo "Usage: $0 [database_path]"
|
|
exit 1
|
|
fi
|
|
|
|
# Run the analysis query
|
|
sqlite3 "$DB_PATH" <<EOF
|
|
.mode column
|
|
.headers on
|
|
.width 36 16 16 17
|
|
|
|
SELECT
|
|
anonymous_id,
|
|
COUNT(*) as completion_count,
|
|
MIN(date) as first_completion,
|
|
MAX(date) as latest_completion
|
|
FROM daily_completions
|
|
GROUP BY anonymous_id
|
|
ORDER BY completion_count DESC
|
|
LIMIT 10;
|
|
EOF
|