Fix: review UI domain breakdown from Qdrant

The review items API endpoint still read concept domain counts from
on-disk JSON files, which would show empty breakdowns for items with
missing concept directories. Replace disk reads with the same
_count_domains_from_qdrant function used by domain assignment.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Matt 2026-04-28 03:59:13 +00:00
commit 043119fbaa

View file

@ -395,35 +395,18 @@ def api_peertube_review_stats():
@app.route('/api/peertube/review/items') @app.route('/api/peertube/review/items')
def api_peertube_review_items(): def api_peertube_review_items():
import json as _json from .domain_assigner import _count_domains_from_qdrant, _get_qdrant_client
from .recon_domains import VALID_DOMAINS
db = StatusDB() db = StatusDB()
config = get_config() config = get_config()
items = db.get_items_by_domain_status('tied_manual', limit=200) items = db.get_items_by_domain_status('tied_manual', limit=200)
qdrant = _get_qdrant_client(config)
collection = config['vector_db']['collection']
result = [] result = []
concepts_dir = config['paths']['concepts']
for item in items: for item in items:
file_hash = item['hash'] file_hash = item['hash']
# Count domains from concept files domain_counter = _count_domains_from_qdrant(qdrant, collection, file_hash)
top_domains = []
doc_concepts_dir = os.path.join(concepts_dir, file_hash)
if os.path.isdir(doc_concepts_dir):
from collections import Counter
domain_counter = Counter()
for fname in os.listdir(doc_concepts_dir):
if not fname.startswith('window_') or not fname.endswith('.json'):
continue
try:
with open(os.path.join(doc_concepts_dir, fname)) as f:
concepts = _json.load(f)
for c in concepts:
if isinstance(c, dict):
dom = c.get('domain')
if isinstance(dom, str) and dom in VALID_DOMAINS:
domain_counter[dom] += 1
except Exception:
continue
top_domains = [{'domain': d, 'count': cnt} top_domains = [{'domain': d, 'count': cnt}
for d, cnt in domain_counter.most_common(5)] for d, cnt in domain_counter.most_common(5)]