-- Queue enrichment jobs for HubSpot List 93
-- This would be run against the production database

DO $$
DECLARE
    list_id INTEGER := 93;
    max_batch_size INTEGER := 10;
    contact_record RECORD;
    batch_count INTEGER := 0;
BEGIN
    -- Log the start of enrichment
    INSERT INTO entity_enrichment_requests (
        request_id,
        entity_type,
        entity_id,
        source_list_id,
        status,
        created_at
    )
    SELECT
        gen_random_uuid(),
        'person',
        contact_id::text,
        list_id,
        'pending',
        NOW()
    FROM hubspot_list_members
    WHERE list_id = list_id
    LIMIT max_batch_size;

    GET DIAGNOSTICS batch_count = ROW_COUNT;

    RAISE NOTICE 'Queued % contacts for enrichment from List %', batch_count, list_id;
END $$;
