← back to Dear Bubbe Nextjs

scripts/weekly-report-for-steve.sh

59 lines

#!/bin/bash

echo "====================================================="
echo "      WEEKLY TWITTER REPORT FOR STEVE"
echo "====================================================="
echo ""
echo "Generated: $(date)"
echo ""

# Check current stats
if [ -f "/root/Projects/dear-bubbe-admin/logs/twitter-stats.json" ]; then
    echo "📊 CURRENT STATS:"
    cat /root/Projects/dear-bubbe-admin/logs/twitter-stats.json | jq '.'
    echo ""
fi

# Count posts in last 7 days
echo "📈 POSTS IN LAST 7 DAYS:"
if [ -f "/root/Projects/dear-bubbe-admin/logs/twitter-posted.json" ]; then
    SEVEN_DAYS_AGO=$(date -d "7 days ago" +%s)
    TOTAL_POSTS=$(cat /root/Projects/dear-bubbe-admin/logs/twitter-posted.json | jq --arg date "$SEVEN_DAYS_AGO" '[.[] | select(.postedAt) | select(((.postedAt | split("T")[0] + "T00:00:00Z") | fromdateiso8601) > ($date | tonumber))] | length')
    echo "Total posts this week: $TOTAL_POSTS"
    echo "Daily average: $((TOTAL_POSTS / 7))"
    echo "API usage: $TOTAL_POSTS / 700 ($(( (TOTAL_POSTS * 100) / 700 ))%)"
else
    echo "No posted data available"
fi
echo ""

# Check PM2 status
echo "🤖 BOT STATUS:"
pm2 list | grep bubbe-twitter-smart
echo ""

# Recent posts
echo "🐦 LAST 5 TWEETS:"
if [ -f "/root/Projects/dear-bubbe-admin/logs/twitter-posted.json" ]; then
    cat /root/Projects/dear-bubbe-admin/logs/twitter-posted.json | jq -r '.[-5:] | reverse | .[] | "• \(.postedAt | split("T")[0]) - \(.url)"' 2>/dev/null
fi
echo ""

echo "====================================================="
echo "RECOMMENDATIONS:"
echo ""

# Calculate usage percentage
if [ "$TOTAL_POSTS" -lt 500 ]; then
    echo "⚠️  Using only $TOTAL_POSTS/700 weekly capacity"
    echo "   Recommendation: Increase posting frequency"
fi

echo "✓ Bot is running 24/7 with PM2"
echo "✓ Rate limiting enforced (1 post per 3 minutes)"
echo "✓ Using viral hashtags for maximum engagement"
echo ""
echo "====================================================="
echo "TO VIEW LIVE POSTS:"
echo "Visit: https://x.com/DearBubbe"
echo "====================================================="