From f20bf03ee16615acf2c621154fa04132b877c8cd Mon Sep 17 00:00:00 2001 From: Lars Date: Tue, 30 Sep 2025 12:37:56 +0200 Subject: [PATCH] =?UTF-8?q?tests/audit=5Fedges=5Fnow.py=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/audit_edges_now.py | 49 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 tests/audit_edges_now.py diff --git a/tests/audit_edges_now.py b/tests/audit_edges_now.py new file mode 100644 index 0000000..67f0014 --- /dev/null +++ b/tests/audit_edges_now.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +tests/audit_edges_now.py — Zählt Edges nach kind & scope und zeigt Chunk- und Note-Anzahl. +""" +import os, sys, json +PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) +if PROJECT_ROOT not in sys.path: + sys.path.insert(0, PROJECT_ROOT) + +from qdrant_client.http import models as rest +from app.core.qdrant import QdrantConfig, get_client + +def scroll_all(c, col, flt=None): + out, nextp = [], None + while True: + pts, nextp = c.scroll(collection_name=col, with_payload=True, with_vectors=False, limit=256, scroll_filter=flt, offset=nextp) + if not pts: break + out.extend(pts) + if nextp is None: break + return out + +def main(): + cfg = QdrantConfig.from_env() + c = get_client(cfg) + notes = f"{cfg.prefix}_notes" + chunks = f"{cfg.prefix}_chunks" + edges = f"{cfg.prefix}_edges" + + es = scroll_all(c, edges) + counts = {} + by_scope = {} + for p in es: + pl = p.payload or {} + k = pl.get("kind") or "?" + s = pl.get("scope") or "?" + counts[k] = counts.get(k, 0) + 1 + key = f"{k}:{s}" + by_scope[key] = by_scope.get(key, 0) + 1 + + print(json.dumps({ + "collections": {"notes": notes, "chunks": chunks, "edges": edges}, + "total_edges": len(es), + "counts": counts, + "counts_by_scope": by_scope + }, ensure_ascii=False, indent=2)) + +if __name__ == "__main__": + main()