Skip to content

Latest commit

 

History

History
133 lines (107 loc) · 4.46 KB

File metadata and controls

133 lines (107 loc) · 4.46 KB

Ready for Deployment - Election Day Data Import

Status: READY TO RUN

All scripts are created and ready. When you return, run this ONE command on the server:

ssh root@politiquera.com "cd /opt/whovoted && bash deploy/import_election_day_only.sh"

What This Will Do

  1. ✓ Download election day voting data from Civix API for ALL counties
  2. ✓ Import Democratic primary voters
  3. ✓ Import Republican primary voters
  4. ✓ Mark voters with unknown party as "Unknown" (gray color on map)
  5. ✓ Show summary statistics
  6. ✗ NO geocoding triggered
  7. ✗ NO cache regeneration

What Was Fixed

1. First-Time Voter Logic (Fixed but not yet applied)

  • Old logic: Counted 180,809 first-time voters (94% of turnout!) - clearly wrong
  • New logic: Conservative two-rule approach
    • Rule 1: Voter was under 18 for ALL prior elections (newly eligible)
    • Rule 2: County has 3+ prior elections AND voter never voted before
  • Expected result: ~5,000-15,000 first-time voters (3-8% of turnout) - realistic

2. Election Day Scraper (Ready to run)

  • Scrapes from: https://goelect.txelections.civixapps.com/ivis-evr-ui/official-election-day-voting-information
  • Handles: All 254 Texas counties
  • Parties: Democratic, Republican, Unknown
  • No geocoding: Saves time and API costs

3. Map Colors (Updated)

  • Blue: Democratic
  • Red: Republican
  • Gray: Unknown party (new - for election day voters where party can't be determined)
  • Purple: Flipped R→D
  • Maroon: Flipped D→R

Files Created

WhoVoted/
├── deploy/
│   ├── election_day_scraper.py          ← Main scraper
│   ├── import_election_day_only.sh      ← Quick import (no geocoding)
│   ├── deploy_election_day_update.sh    ← Full deployment (with fixes)
│   ├── fix_new_voter_flags.py           ← Fix first-time voter logic
│   └── audit_first_time_voter_logic.py  ← Audit script
├── backend/
│   ├── database.py                       ← Updated with new first-time logic
│   ├── app.py                            ← Updated API endpoints
│   └── reports.py                        ← Updated report generation
├── public/
│   └── map.js                            ← Updated with "unknown" party color
└── Documentation/
    ├── ELECTION_DAY_IMPORT_README.md     ← Full instructions
    ├── FINAL_FIRST_TIME_LOGIC.md         ← Logic documentation
    ├── FIRST_TIME_VOTER_FIX.md           ← Deployment guide
    └── DEPLOYMENT_READY.md               ← This file

After Import (When You Return)

Option A: Just Import Data (Fastest)

ssh root@politiquera.com "cd /opt/whovoted && bash deploy/import_election_day_only.sh"

Time: ~5-10 minutes

Option B: Full Deployment (Recommended)

ssh root@politiquera.com "cd /opt/whovoted && bash deploy/deploy_election_day_update.sh"

Time: ~20-30 minutes

This includes:

  1. Fix first-time voter flags
  2. Import election day data
  3. Regenerate district cache (TX-15)
  4. Regenerate county reports
  5. Regenerate gazette cache

Verification

After running, check the website:

  1. Go to https://politiquera.com/
  2. Check TX-15 district
  3. Verify numbers look reasonable:
    • Total voters: ~192,000
    • First-time voters: ~5,000-15,000 (not 180,000!)
    • Election day voters: ~50-60% of total
    • Gray markers: Unknown party voters (should be minimal)

What's NOT Happening

  • ✗ No geocoding (saves time and API costs)
  • ✗ No automatic cache regeneration (unless you run Option B)
  • ✗ No changes to existing early voting data
  • ✗ No changes to main website until caches are regenerated

Rollback Plan

If something goes wrong:

# Restore database from backup
ssh root@politiquera.com "cd /opt/whovoted && sqlite3 data/whovoted.db < backup.sql"

# Or just delete election day records
ssh root@politiquera.com "cd /opt/whovoted && python3 -c \"
import sys
sys.path.insert(0, '/opt/whovoted/backend')
import database as db
with db.get_db() as conn:
    conn.execute('DELETE FROM voter_elections WHERE voting_method = \\\"election-day\\\" AND election_date = \\\"2026-03-03\\\"')
    conn.commit()
    print('Deleted election day records')
\""

Summary

Everything is ready. The scripts will:

  • Import election day data for all counties
  • Handle unknown party voters gracefully (gray markers)
  • Not trigger geocoding
  • Show you summary statistics

When you're ready, just run the command at the top of this file.