Files
bibdle/scripts/seed-fake-completions.sh
2026-02-21 16:17:06 -05:00

27 lines
814 B
Bash
Executable File
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.
#!/bin/zsh
# Seed the database with 10 fake completions with random anonymous_ids
# Useful for testing streak percentile and stats features
DB_PATH="dev.db"
TODAY=$(date +%Y-%m-%d)
NOW=$(date +%s)
echo "Seeding 10 fake completions for date: $TODAY"
for i in {1..50}; do
ID=$(uuidgen | tr '[:upper:]' '[:lower:]')
ANON_ID=$(uuidgen | tr '[:upper:]' '[:lower:]')
GUESS_COUNT=$(( (RANDOM % 6) + 1 )) # 16 guesses
sqlite3 "$DB_PATH" "
INSERT OR IGNORE INTO daily_completions (id, anonymous_id, date, guess_count, completed_at)
VALUES ('$ID', '$ANON_ID', '$TODAY', $GUESS_COUNT, $NOW);
"
echo " [$i] anon=$ANON_ID guesses=$GUESS_COUNT"
done
TOTAL=$(sqlite3 "$DB_PATH" "SELECT COUNT(*) FROM daily_completions WHERE date = '$TODAY';")
echo "✓ Done. Total completions for $TODAY: $TOTAL"