#!/usr/bin/env python3
"""hc54 quick check: LI queue membership + pending Threads/FB traces for chosen slugs."""
import json, re, sys
WS = "/home/mantapman/.hermes/profiles/atun/workspace"
sys.path.insert(0, WS)
from repliz_client import ACC
docs = json.load(open('/tmp/repliz_all_20261002.json'))
url_re = re.compile(r"studiosoft\.id/([a-z0-9\-]+)")

li_slugs = set()
for d in docs:
    if d.get('accountId') == ACC.STUDIOSOFT_LINKEDIN and (d.get('status') or '').lower() in ('pending', 'scheduled', 'draft'):
        li_slugs |= set(url_re.findall((d.get('description') or '') + ' ' + (d.get('title') or '')))

for s in ['konsultan-pemasaran-digital', 'jasa-digital-marketing-klinik',
          'panduan-seo-klinik-rumah-sakit', 'pembuatan-website-rumah-sakit',
          'jasa-digital-marketing-rs', 'google-business-profile-klinik']:
    print('LI-queue?', s, s in li_slugs)
print('TOTAL distinct LI slugs in queue:', len(li_slugs))

for acc, name in [(ACC.STUDIOSOFT_THREADS, 'THREADS'), (ACC.STUDIOSOFT_FB, 'FB')]:
    for slug in ['jasa-digital-marketing-klinik', 'panduan-seo-klinik-rumah-sakit']:
        for d in docs:
            if d.get('accountId') == acc and (d.get('status') or '').lower() in ('pending', 'scheduled', 'draft'):
                t = (d.get('description') or '') + ' ' + (d.get('title') or '')
                if slug in url_re.findall(t):
                    print(name, slug, 'PENDING', (d.get('scheduleAt') or '')[:16], d.get('_id'))

# Threads 09:00Z booked (all pending)
booked = sorted(set((d.get('scheduleAt') or '')[:16] for d in docs
                    if d.get('accountId') == ACC.STUDIOSOFT_THREADS
                    and (d.get('scheduleAt') or '')[11:16] == '02:00'
                    and (d.get('status') or '').lower() in ('pending', 'scheduled', 'draft')))
print('THREADS 09:00WIB booked:', booked)
