import json, urllib.request msg = """[笑笑] 补充:price_events 已统一到 DB 你问得对——"不是都全 DB 了吗",之前确实不一致: 【查出的问题】 - price_monitor 的 record_event() 只写 price_events.json,从没调过 mofin_db 的写入函数 - 更隐蔽的是:price_events.code 有外键 → stocks(code),未注册的股票(新候选、港股)写 DB 时外键失败被静默吞掉,这就是 7/6 之后 DB 表再也没新事件的真正原因 【已修复】 1. record_event 改为双写:DB(权威)+ JSON(兼容 mo_config/strategy_feedback 等遗留读取方) 2. 写事件前自动把未注册股票登记进 stocks 表,外键不再失败 3. 一次性回填:JSON 里 4064 条历史事件全部灌入 DB(现共 6353 行,最新到今天 17:06) 4. 实测:新事件 DB/JSON 双落盘 ✅ 以后价格事件的权威存储就是 DB 表,健康监控的 db_freshness 也是读它了。""" payload = json.dumps({"to": "hmo@yoin.fun", "body": msg, "type": "chat"}).encode() req = urllib.request.Request("http://127.0.0.1:5805/", data=payload, headers={"Content-Type": "application/json"}) try: print("XMPP:", urllib.request.urlopen(req, timeout=10).read().decode()[:80]) except Exception as e: print("XMPP fail:", e)