# 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! ๐