import json

# Only these machines were actually serviced
serviced_machines = [
    'MHA-e25740e8',  # Lenovo MSERIES - Hassan and Joseph
    'MHA-59ee9a7d',  # Lenovo MSERIES - Hassan and Joseph
    'MHA-fe0e8bb0',  # HP 800G1 SSF - Hassan and Joseph
    'MHA-9d58c1ad',  # HPCOMPAQ 6200 SSF - Hassan and Joseph
    'MHA-379fe2ec',  # Lenovo MSERIES - Hassan and Joseph
    'MHA-cecda398',  # Test-PC - Hassan and Joseph
]

# Load machines
with open('machines.json', 'r', encoding='utf-8') as f:
    machines = json.load(f)

# Clear service dates for machines NOT in the list
cleared_count = 0
kept_count = 0

for machine in machines:
    if machine['machine_code'] in serviced_machines:
        kept_count += 1
        print(f"✓ KEPT: {machine['machine_code']} - {machine.get('computer_name', 'Unknown')}")
    else:
        # Clear service date
        machine['last_service_repaste'] = None
        cleared_count += 1

# Save back
with open('machines.json', 'w', encoding='utf-8') as f:
    json.dump(machines, f, indent=4, ensure_ascii=False)

print(f"\n✅ Done!")
print(f"   Kept service logs: {kept_count} machines")
print(f"   Cleared service logs: {cleared_count} machines")
