51 lines
1.6 KiB
Python
51 lines
1.6 KiB
Python
import json
|
|
import os
|
|
import glob
|
|
|
|
def main():
|
|
uploads_dir = "backend/uploads"
|
|
if not os.path.exists(uploads_dir):
|
|
uploads_dir = "uploads"
|
|
|
|
manual_pattern = os.path.join(uploads_dir, "manual_label_*.json")
|
|
manual_files = glob.glob(manual_pattern)
|
|
|
|
target_store = "PX HEAD OFFICE ANCOL"
|
|
target_alamat = "JL. ANCOL BARAT VIII/1 KEL. ANCOL, KEC. PADEMANGAN JAKARTA UTARA, DKI JAKARTA"
|
|
target_customer = "PT. PRIMAFOOD INTERNATIONAL"
|
|
fixed_count = 0
|
|
|
|
for mf in manual_files:
|
|
try:
|
|
with open(mf, "r", encoding="utf-8") as f:
|
|
data = json.load(f)
|
|
|
|
is_modified = False
|
|
|
|
# Fix customer
|
|
current_customer = data.get("customer", "")
|
|
if current_customer != target_customer:
|
|
data["customer"] = target_customer
|
|
is_modified = True
|
|
|
|
# Fix store
|
|
store = data.get("store", "")
|
|
if store == "DKI AREA":
|
|
data["store"] = target_store
|
|
data["alamat"] = target_alamat
|
|
is_modified = True
|
|
|
|
if is_modified:
|
|
with open(mf, "w", encoding="utf-8") as f:
|
|
json.dump(data, f, indent=2, ensure_ascii=False)
|
|
|
|
print(f"Updated manual label: {mf}")
|
|
fixed_count += 1
|
|
except Exception as e:
|
|
print(f"Error updating {mf}: {e}")
|
|
|
|
print(f"Finished updating manual label files. Total files updated: {fixed_count}")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|