| 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 : |
import json, random, string
db = json.load(open("/home/rmlac2fmr/public_html/jn.com/ops/data/db.json"))
def new_id():
return "P" + str(random.randint(10000000, 99999999)) + ''.join(random.choices(string.ascii_lowercase, k=3))
def relink(old_id, new_id, person_name):
"""Update all references from old_id to new_id for a specific person"""
count = 0
for a in db.get("assignments", []):
if a.get("personId") == old_id:
# Check if this assignment belongs to the person we're relinking
# We can't tell from assignment alone, so we'll relink all
pass
# For assignments, we need to be careful — both people have the same ID
# We'll handle this by checking which person has travel requests
for r in db.get("travelRequests", []):
if r.get("personId") == old_id and person_name.lower() in r.get("submittedName", "").lower():
r["personId"] = new_id
count += 1
print(f" Relinked travel request {r['id']} ({r.get('submittedName','')})")
for h in db.get("hotelBookings", []):
if h.get("personId") == old_id and person_name.split()[-1].lower() in h.get("lastName", "").lower():
h["personId"] = new_id
count += 1
print(f" Relinked hotel booking {h['id']}")
for pd in db.get("perDiems", []):
if pd.get("personId") == old_id:
# Check via reqId
req = next((r for r in db["travelRequests"] if r["id"] == pd.get("reqId","") and person_name.lower() in r.get("submittedName","").lower()), None)
if req:
pd["personId"] = new_id
count += 1
print(f" Relinked per diem {pd['id']}")
for ap in db.get("approvals", []):
if ap.get("personId") == old_id and person_name.split()[-1].lower() in ap.get("description", "").lower():
ap["personId"] = new_id
count += 1
print(f" Relinked approval {ap['id']}")
return count
# Fix collision 1: Len Applefeld gets new ID (Matt Nowak keeps P26340720)
print("=== Fixing Collision 1: Matt Nowak / Len Applefeld (P26340720) ===")
len_new_id = new_id()
len_person = next((p for p in db["persons"] if p["id"] == "P26340720" and "applefeld" in p.get("lastName","").lower()), None)
if len_person:
print(f" Len Applefeld: old={len_person['id']} -> new={len_new_id}")
len_person["id"] = len_new_id
ct = relink("P26340720", len_new_id, "Applefeld")
# Fix assignments — find any that should belong to Len
for a in db.get("assignments", []):
if a.get("personId") == "P26340720":
# Keep for Matt, duplicate for Len
pass
# Create assignment for Len if missing
len_assignments = [a for a in db["assignments"] if a["personId"] == len_new_id]
if not len_assignments:
db["assignments"].append({"id": "A" + str(random.randint(100000000,999999999)), "personId": len_new_id, "showId": "S2"})
print(f" Created NMDC2026 assignment for Len")
print(f" Relinked {ct} records")
else:
print(" Len Applefeld not found!")
# Fix collision 2: Jay Hall gets new ID (Samantha Seymour keeps P26340742)
print("\n=== Fixing Collision 2: Samantha Seymour / Jay Hall (P26340742) ===")
jay_new_id = new_id()
jay_person = next((p for p in db["persons"] if p["id"] == "P26340742" and "hall" in p.get("lastName","").lower()), None)
if jay_person:
print(f" Jay Hall: old={jay_person['id']} -> new={jay_new_id}")
jay_person["id"] = jay_new_id
ct = relink("P26340742", jay_new_id, "Hall")
# Create assignment for Jay if missing
jay_assignments = [a for a in db["assignments"] if a["personId"] == jay_new_id]
if not jay_assignments:
db["assignments"].append({"id": "A" + str(random.randint(100000000,999999999)), "personId": jay_new_id, "showId": "S2"})
print(f" Created NMDC2026 assignment for Jay")
print(f" Relinked {ct} records")
else:
print(" Jay Hall not found!")
# Also fix Samantha's last name: "A. Seymour" -> lastName="Seymour", middleName="A."
print("\n=== Fixing Samantha's name ===")
sam = next((p for p in db["persons"] if p["id"] == "P26340742"), None)
if sam and "A." in sam.get("lastName", ""):
sam["middleName"] = "A."
sam["lastName"] = "Seymour"
print(f" Fixed: {sam['firstName']} {sam.get('middleName','')} {sam['lastName']}")
# Verify no more collisions
print("\n=== Verification ===")
ids = {}
dupes = 0
for p in db["persons"]:
if p["id"] in ids:
dupes += 1
print(f" ⚠ Still duplicate: {p['id']} ({ids[p['id']]['firstName']} {ids[p['id']]['lastName']} / {p['firstName']} {p['lastName']})")
else:
ids[p["id"]] = p
print(f" Duplicate IDs remaining: {dupes}")
json.dump(db, open("/home/rmlac2fmr/public_html/jn.com/ops/data/db.json", "w"), indent=2)
print("\nDone! Restart server.")