from worker.stylist_engine import StylistEngine
from collections import Counter

e = StylistEngine()
catalog = e._get_catalog()

# Group product_lines by gender
lines_by_gender = {}
for p in catalog:
    g = p.get('gender', 'unknown')
    pl = p.get('product_line', '')
    if not pl:
        continue
    if g not in lines_by_gender:
        lines_by_gender[g] = Counter()
    lines_by_gender[g][pl] += 1

print("=== WOMEN product_lines ===")
for pl, cnt in sorted(lines_by_gender.get('women', {}).items(), key=lambda x: -x[1]):
    print(f"  {cnt:3d}x  {pl}")

print()
print("=== MEN product_lines ===")
for pl, cnt in sorted(lines_by_gender.get('men', {}).items(), key=lambda x: -x[1]):
    print(f"  {cnt:3d}x  {pl}")

print()
print("=== UNISEX product_lines ===")
for pl, cnt in sorted(lines_by_gender.get('unisex', {}).items(), key=lambda x: -x[1]):
    print(f"  {cnt:3d}x  {pl}")

print()
print("=== ALL unique genders in catalog ===")
print(set(p.get('gender','') for p in catalog))
