44 lines
1.2 KiB
Bash
Executable File
44 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
# Analyse des résultats warmup pour Brain Engine
|
|
# Usage: ./analyze-warmup.sh [batch_id]
|
|
|
|
BATCH_ID=${1:-""}
|
|
|
|
echo "=== ANALYSE WARMUP BRAIN ENGINE ==="
|
|
|
|
PGPASSWORD=admin123 psql -U admin -d adx_system << EOSQL
|
|
-- Stats par ISP
|
|
SELECT
|
|
recipient_isp,
|
|
COUNT(*) as total_sent,
|
|
SUM(CASE WHEN opened THEN 1 ELSE 0 END) as opens,
|
|
SUM(CASE WHEN clicked THEN 1 ELSE 0 END) as clicks,
|
|
SUM(CASE WHEN bounced THEN 1 ELSE 0 END) as bounces,
|
|
ROUND(100.0 * SUM(CASE WHEN NOT bounced THEN 1 ELSE 0 END) / COUNT(*), 2) as delivery_rate
|
|
FROM admin.brain_warmup_tests
|
|
${BATCH_ID:+WHERE test_batch_id = '$BATCH_ID'}
|
|
GROUP BY recipient_isp
|
|
ORDER BY total_sent DESC;
|
|
|
|
-- Stats par config
|
|
SELECT
|
|
config_type,
|
|
headers_variant,
|
|
COUNT(*) as total,
|
|
ROUND(100.0 * SUM(CASE WHEN NOT bounced THEN 1 ELSE 0 END) / COUNT(*), 2) as delivery_rate
|
|
FROM admin.brain_warmup_tests
|
|
${BATCH_ID:+WHERE test_batch_id = '$BATCH_ID'}
|
|
GROUP BY config_type, headers_variant;
|
|
|
|
-- Derniers batches
|
|
SELECT
|
|
test_batch_id,
|
|
COUNT(*) as emails,
|
|
MIN(sent_at) as started,
|
|
MAX(sent_at) as ended
|
|
FROM admin.brain_warmup_tests
|
|
GROUP BY test_batch_id
|
|
ORDER BY MIN(sent_at) DESC
|
|
LIMIT 10;
|
|
EOSQL
|