| Server IP : 216.92.14.13 / Your IP : 216.73.217.126 Web Server : Apache System : Linux vps4089.pairvps.com 5.15.0-190-generic #200-Ubuntu SMP Fri Aug 7 15:06:04 UTC 2026 x86_64 User : rmlac2fmr ( 1040637) PHP Version : 8.2.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/home/rmlac2fmr/ |
Upload File : |
#!/usr/bin/env python3
"""
JBT Travel Ops — Bryan Dozier Complete Removal
Removes ALL traces of Bryan Dozier from the database:
- Person profile
- Both travel requests (NMDC S2 + ACF S3)
- Per diem record
- Assignment to NMDC
Per diagnostic run on May 6, target IDs are:
- Person: P71770558
- TR S2: R1777771770558
- TR S3: R1777771808089
- PD: PDR1777771770558
- Assign: A1777771770558
Creates a timestamped backup of db.json before writing.
"""
import json
import os
import sys
import shutil
from datetime import datetime
PERSON_ID = 'P71770558'
REQ_IDS = ['R1777771770558', 'R1777771808089']
candidates = [
'db.json',
'./data/db.json',
os.path.expanduser('~/public_html/jn.com/ops/data/db.json')
]
db_path = next((c for c in candidates if os.path.exists(c)), None)
if not db_path:
print("ERROR: db.json not found")
sys.exit(1)
# Backup
backup_path = db_path + '.backup-' + datetime.now().strftime('%Y%m%d-%H%M%S')
shutil.copy2(db_path, backup_path)
print(f"✓ Backup created: {backup_path}\n")
with open(db_path, 'r') as f:
db = json.load(f)
# Verify person exists before doing anything
person = next((p for p in db.get('persons', []) if p.get('id') == PERSON_ID), None)
if not person:
print(f"⚠ Person {PERSON_ID} not found — already removed? Aborting to be safe.")
sys.exit(1)
print(f"Found: {person.get('firstName','')} {person.get('lastName','')} ({person.get('email','')})")
print()
removed = {
'persons': 0,
'travelRequests': 0,
'perDiems': 0,
'assignments': 0,
'approvals': 0,
'hotelBookings': 0,
'bookings': 0,
'notes': 0,
'discrepancyStatus': 0
}
# Remove person
before = len(db.get('persons', []))
db['persons'] = [p for p in db.get('persons', []) if p.get('id') != PERSON_ID]
removed['persons'] = before - len(db['persons'])
# Remove all travel requests for this person (catches both S2 and S3)
before = len(db.get('travelRequests', []))
db['travelRequests'] = [r for r in db.get('travelRequests', []) if r.get('personId') != PERSON_ID]
removed['travelRequests'] = before - len(db['travelRequests'])
# Remove per diems linked by personId or reqId
before = len(db.get('perDiems', []))
db['perDiems'] = [pd for pd in db.get('perDiems', [])
if pd.get('personId') != PERSON_ID and pd.get('reqId') not in REQ_IDS]
removed['perDiems'] = before - len(db['perDiems'])
# Remove assignments
before = len(db.get('assignments', []))
db['assignments'] = [a for a in db.get('assignments', []) if a.get('personId') != PERSON_ID]
removed['assignments'] = before - len(db['assignments'])
# Remove approvals (defensive)
before = len(db.get('approvals', []))
db['approvals'] = [a for a in db.get('approvals', []) if a.get('personId') != PERSON_ID]
removed['approvals'] = before - len(db['approvals'])
# Remove hotel bookings (defensive)
before = len(db.get('hotelBookings', []))
db['hotelBookings'] = [h for h in db.get('hotelBookings', []) if h.get('personId') != PERSON_ID]
removed['hotelBookings'] = before - len(db['hotelBookings'])
# Remove legacy bookings (defensive)
before = len(db.get('bookings', []))
db['bookings'] = [b for b in db.get('bookings', []) if b.get('personId') != PERSON_ID]
removed['bookings'] = before - len(db['bookings'])
# Remove notes (defensive)
before = len(db.get('notes', []))
db['notes'] = [n for n in db.get('notes', []) if n.get('personId') != PERSON_ID]
removed['notes'] = before - len(db['notes'])
# Remove discrepancy status entries keyed to this person/request
disc = db.get('discrepancyStatus') or {}
keys_to_remove = []
for key in list(disc.keys()):
if PERSON_ID in key or any(rid in key for rid in REQ_IDS):
keys_to_remove.append(key)
for k in keys_to_remove:
del disc[k]
db['discrepancyStatus'] = disc
removed['discrepancyStatus'] = len(keys_to_remove)
# Save
with open(db_path, 'w') as f:
json.dump(db, f, indent=2)
print("=" * 60)
print("REMOVAL COMPLETE")
print("=" * 60)
total = sum(removed.values())
for collection, count in removed.items():
if count > 0:
print(f" ✓ {collection}: {count} record{'s' if count != 1 else ''} removed")
if total == 0:
print(" (nothing was removed — already clean?)")
else:
print(f"\n Total: {total} records removed across all collections")
print(f"\n Backup at: {backup_path}")
print()
print("NEXT STEPS:")
print(" 1. Restart Node so server reloads cleaned DB:")
print(" kill -9 `lsof -t -i :3000`")
print(" 2. Hard-refresh browser to clear cached state")
print(" 3. Verify Bryan is gone from:")
print(" - Crew Database")
print(" - NMDC and ACF travel requests")
print(" - Hotel Attention dashboard widget")
print(" - Per Diem grid")