Bash

curl -s "https://mssql.danmarcrm.com/dev1/extension2v1/public/api.php?action=load_deep_analysis&thread_id=18668e45237c2001" 2>/dev/null | python3 -c "
import sys, json
d = json.load(sys.stdin)
print('Passes:', len(d.get('passes',[])))
for p in d.get('passes',[]):
    print('  Pass', p['pass'], '-', p['name'], ':', len(p['responses']), 'responses')
"

Test load_deep_analysis with fixed signature ordering


Passes: 5
  Pass 1 - Business Relationship Timeline : 2 responses
  Pass 2 - Pressure & Manipulation Detection : 2 responses
  Pass 3 - Psychological Profiles : 2 responses
  Pass 4 - Financial & Business Patterns : 2 responses
  Pass 5 - Win-Back Strategy : 2 responses


All 5 passes, 2 responses each (claude + openai), correctly detected. Now let me also make sure the `$hasDeepAnalysis` PHP variable works for this thread — the PHP check uses `deep_analysis_pass` which doesn't exist for these old records. I should add the same fallback there:


Edit

// Check if deep analysis exists for this thread
$hasDeepAnalysis = $mongo->count('ai_query_responses', [
    'thread_ids' => $threadId,
    'deep_analysis_pass' => ['$exists' => true]
]) > 0;

// Check if deep analysis exists for this thread (tagged or detected by question patterns)
$hasDeepAnalysis = $mongo->count('ai_query_responses', [
    'thread_ids' => $threadId,
    'deep_analysis_pass' => ['$exists' => true]
]) > 0;
if (!$hasDeepAnalysis) {
    // Fallback: check if there's a response matching the timeline pass question
    $hasDeepAnalysis = $mongo->count('ai_query_responses', [
        'thread_ids' => $threadId,
        'question' => ['$regex' => 'Analyze the COMPLETE email history chronologically']
    ]) > 0;
}