|
|
|
"""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 |
|
|
|
|
|
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 |
|
|
|
|
|
product_pattern = r'<Product>(.*?)</Product>' |
|
all_products = re.findall(product_pattern, xml_text, re.DOTALL) |
|
|
|
print(f"Total products: {len(all_products)}") |
|
|
|
|
|
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)}") |
|
|
|
|
|
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']: |
|
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 |
|
|
|
|
|
print("\n" + "="*60) |
|
print("WHAT GPT-5 RECEIVES:") |
|
print("="*60) |
|
print(f"Total products sent to GPT-5: {len(products_summary)}") |
|
|
|
|
|
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 |
|
|
|
|
|
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}") |
|
|
|
|
|
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!") |