# HTML Entity Cleaning Tool This tool permanently cleans HTML entities and tags from all text fields in the database. ## Quick Start ```bash # Set your database URL (if not already set) export DATABASE_URL="postgresql://user:pass@localhost/church_api" # Run the cleaning tool cargo run --bin clean-html-entities ``` ## What it does ๐Ÿงน **Removes HTML tags**: `

`, `

`, ``, etc. ๐Ÿ”ง **Converts HTML entities**: - ` ` โ†’ space - `&` โ†’ `&` - `<` โ†’ `<` - `>` โ†’ `>` - `"` โ†’ `"` - `'` โ†’ `'` ## Tables cleaned โœ… **bulletins**: title, sabbath_school, divine_worship, scripture_reading, sunset โœ… **events**: title, description, location, location_url, approved_from โœ… **pending_events**: title, description, location, location_url, admin_notes, submitter_email, bulletin_week โœ… **members**: first_name, last_name, address, notes, emergency_contact_name, membership_status โœ… **church_config**: church_name, contact_email, church_address, po_box, google_maps_url, about_text โœ… **users**: username, email, name, avatar_url, role โœ… **media_items**: title, speaker, description, scripture_reading (if table exists) โœ… **transcoded_media**: error_message, transcoding_method (if table exists) ## Safety features - โšก **Smart**: Only processes records that actually need cleaning - ๐Ÿ“Š **Informative**: Shows exactly how many records were cleaned - ๐Ÿ” **Verification**: Counts dirty records before and after - โฑ๏ธ **Fast**: Uses existing sanitization functions from your codebase ## Example output ``` ๐Ÿงน Church API - HTML Entity Cleaning Tool ========================================== ๐Ÿ“ก Connecting to database... โœ… Connected successfully! ๐Ÿ” Analyzing database for HTML entities... ๐Ÿ“Š Found 23 records with HTML tags or entities ๐Ÿš€ Starting HTML entity cleanup... ๐Ÿ”ง Cleaning bulletins table... โœ… Cleaned 5 bulletin records ๐Ÿ”ง Cleaning events table... โœ… Cleaned 12 event records ๐Ÿ”ง Cleaning pending_events table... โœ… Cleaned 3 pending event records ๐Ÿ”ง Cleaning members table... โœ… Cleaned 2 member records ๐Ÿ”ง Cleaning church_config table... โœ… Cleaned 1 church config records ๐Ÿ”ง Cleaning users table... โœ… Cleaned 0 user records ๐Ÿ”ง Cleaning media_items table... โœ… Cleaned 0 media item records ๐Ÿ”ง Cleaning transcoded_media table... โœ… Cleaned 0 transcoded media records ๐ŸŽ‰ Cleanup completed! ๐Ÿ“Š Total records cleaned: 23 โฑ๏ธ Duration: 145ms ๐Ÿ” Verifying cleanup... โœ… Success! No HTML entities remaining in database. ``` ## Benefits after running ๐Ÿš€ **Faster API responses** - No more cleaning on every request ๐Ÿ”’ **Clean database** - All text data is now pure and clean ๐Ÿ“Š **Better queries** - Direct database queries return clean data ๐Ÿ›ก๏ธ **Complete solution** - Works with the existing API sanitization Your API will now return completely clean data with no HTML entities! ๐ŸŽ‰