import collections import sqlite3 import sys sys.path.insert(0, ".") from omni import sources, taxonomy # noqa: E402 src = sources.all_sources() by_cat = collections.Counter(s.category for s in src) con = sqlite3.connect("data/" + "omni.sqlite3") items = con.execute("select count(*) from items").fetchone()[0] priced = con.execute("select count(*) from items where price is not null and price>0").fetchone()[0] runs = con.execute("select count(*) from runs").fetchone()[0] xn = con.execute("select count(*) from items where provider='x'").fetchone()[0] flat = collections.Counter() for combo, n in con.execute("select types,count(*) from items where types!='' group by 1"): for t in str(combo).split(","): if t.strip(): flat[t.strip()] += n print(f"sources={len(src)} items={items} priced={priced} runs={runs} x={xn}") print(" · ".join(f"{taxonomy.LABELS.get(k, k)} {v}" for k, v in flat.most_common())) open("data/_cats.md", "w", encoding="utf-8").write( "\n".join(f"| `{c}` | {n} |" for c, n in by_cat.most_common())) open("data/_types.md", "w", encoding="utf-8").write( " · ".join(f"{taxonomy.LABELS.get(k, k)} {v}" for k, v in flat.most_common()))