#!/usr/bin/env python3 """Разделить support-очередь на host/PC шарды (по hash URL).""" import hashlib import json import os OUT = "/opt/work-hub/research" src = os.path.join(OUT, "queue-retry-support.jsonl") rows = [json.loads(l) for l in open(src, encoding="utf-8") if l.strip()] pc, host = [], [] for x in rows: h = int(hashlib.sha1(x["url"].encode()).hexdigest(), 16) (pc if h % 2 == 0 else host).append(x) for name, data in (("queue-support-pc.jsonl", pc), ("queue-support-host.jsonl", host)): with open(os.path.join(OUT, name), "w", encoding="utf-8") as f: for x in data: f.write(json.dumps(x, ensure_ascii=False) + "\n") print("pc", len(pc), "host", len(host), "total", len(rows))