# -*- coding: utf-8 -*-
import json, os
B=r"C:\Users\daito\company\projects\kototoi-sanpo-editorial\meiten-business\data"
open(os.path.join(B,"activity.jsonl"),"w",encoding="utf-8").close()
M=os.path.join(B,"meiten-master.json"); j=json.load(open(M,encoding="utf-8"))
c=0
for s in j["stores"]:
    cb=(s.get("claimedBy") or "")
    if "テスト" in cb or "test" in cb.lower():
        s.pop("claimedBy",None); s.pop("claimedAt",None); c+=1
    v=s.get("vol16") or {}
    rp=(v.get("rep") or "")
    if "テスト" in rp or "test" in rp.lower():
        # 実担当へ戻す（salesRepsの先頭 or 空）
        real=""
        for r in (s.get("salesReps") or []):
            if r.get("rep"): real=r["rep"]; break
        v["rep"]=real or "未割当"; c+=1
json.dump(j,open(M,"w",encoding="utf-8"),ensure_ascii=False,indent=2)
print("test data removed:",c)
