File size: 3,852 Bytes
916ea95
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/usr/bin/env python3
"""Direct test without GPT-5 to see what's in the data"""

import sys
import os
sys.path.insert(0, '/home/samikoen/bf_wab_space')

import requests
import re
import json

# Get warehouse XML
print("Fetching warehouse XML...")
url = 'https://video.trek-turkey.com/bizimhesap-warehouse-xml-b2b-api-v2.php'
response = requests.get(url, verify=False, timeout=15)
xml_text = response.text

# Extract products
product_pattern = r'<Product>(.*?)</Product>'
all_products = re.findall(product_pattern, xml_text, re.DOTALL)

print(f"Total products: {len(all_products)}")

# Create products_summary EXACTLY like the function
products_summary = []
for i, product_block in enumerate(all_products):
    name_match = re.search(r'<ProductName><!\[CDATA\[(.*?)\]\]></ProductName>', product_block)
    variant_match = re.search(r'<ProductVariant><!\[CDATA\[(.*?)\]\]></ProductVariant>', product_block)
    
    if name_match:
        warehouses_with_stock = []
        warehouse_regex = r'<Warehouse>.*?<Name><!\[CDATA\[(.*?)\]\]></Name>.*?<Stock>(.*?)</Stock>.*?</Warehouse>'
        warehouses = re.findall(warehouse_regex, product_block, re.DOTALL)
        
        for wh_name, wh_stock in warehouses:
            try:
                if int(wh_stock.strip()) > 0:
                    warehouses_with_stock.append(wh_name)
            except:
                pass
        
        product_info = {
            "index": i,
            "name": name_match.group(1),
            "variant": variant_match.group(1) if variant_match else "",
            "warehouses": warehouses_with_stock
        }
        products_summary.append(product_info)

print(f"Products in summary: {len(products_summary)}")

# Search for MADONE and MARLIN
print("\n" + "="*60)
print("SEARCHING FOR MADONE SL 6:")
print("="*60)

madone_found = []
for p in products_summary:
    if "MADONE SL 6" in p['name'].upper():
        madone_found.append(p)
        
if madone_found:
    print(f"✅ Found {len(madone_found)} MADONE SL 6 products:")
    for p in madone_found:
        if p['warehouses']:  # Only show products with stock
            print(f"  Index {p['index']}: {p['name']} - {p['variant']}")
            print(f"    Stock in: {', '.join(p['warehouses'])}")
else:
    print("❌ No MADONE SL 6 found!")

print("\n" + "="*60)
print("SEARCHING FOR MARLIN:")
print("="*60)

marlin_found = []
for p in products_summary:
    if "MARLIN" in p['name'].upper():
        marlin_found.append(p)

if marlin_found:
    print(f"Found {len(marlin_found)} MARLIN products")
    print("First 3 MARLIN products with stock:")
    count = 0
    for p in marlin_found:
        if p['warehouses'] and count < 3:
            print(f"  Index {p['index']}: {p['name']} - {p['variant']}")
            print(f"    Stock in: {', '.join(p['warehouses'])}")
            count += 1

# Check what GPT-5 would receive
print("\n" + "="*60)
print("WHAT GPT-5 RECEIVES:")
print("="*60)
print(f"Total products sent to GPT-5: {len(products_summary)}")

# Check indices around MADONE
print("\nProducts at indices 460-475:")
for idx in range(460, 476):
    for p in products_summary:
        if p['index'] == idx:
            has_stock = "✅" if p['warehouses'] else "❌"
            print(f"  {idx} {has_stock}: {p['name'][:30]}...")
            break

# Save the exact data GPT-5 receives
output_file = '/home/samikoen/gpt5_exact_input.json'
with open(output_file, 'w', encoding='utf-8') as f:
    json.dump(products_summary, f, ensure_ascii=False, indent=2)
print(f"\n💾 Saved exact GPT-5 input to: {output_file}")

# Show what indices GPT-5 should return for "madone sl 6"
madone_indices = [str(p['index']) for p in madone_found if p['warehouses']]
if madone_indices:
    print(f"\n🎯 GPT-5 SHOULD RETURN: {','.join(madone_indices)}")
else:
    print("\n⚠️ No MADONE SL 6 with stock found!")