import re print("Aligning VIP room fields and fixing rendering in live_marketing_index.html...") with open('/workspace/live_marketing_index.html', 'r', encoding='utf-8') as f: html = f.read() # Replace the VIP card mapping section in renderGoogleAdsB2BView old_vip_map = """
${data.vip_rooms.map(room => { let isCrit = room.status === 'critical'; let isWarn = room.status === 'warning'; let badgeBg = isCrit ? '#FFE4E6' : (isWarn ? '#FEF3C7' : '#DCFCE7'); let badgeColor = isCrit ? '#9F1239' : (isWarn ? '#92400E' : '#166534'); let badgeText = isCrit ? '⚠️ بحرانی (فاصله زیاد از تارگت)' : (isWarn ? '⚡ نیازمند توجه' : '✅ در مسیر تارگت'); return `
${room.room_name}
${room.genre} | ظرفیت: ${room.capacity_per_slot} نفر
${badgeText}
رزرو شده: ${room.booked_slots} از ${room.target_slots} سانس ${room.completion_pct}%
💡 اکشن فوری سوشال: ${room.suggested_rescue_action}
قیمت بلیت: ${room.ticket_price_toman.toLocaleString('fa-IR')} تومان
`; }).join('')}
""" new_vip_map = """
${data.vip_rooms.map(room => { let isCrit = room.status === 'critical'; let isWarn = room.status === 'warning'; let badgeBg = isCrit ? '#FFE4E6' : (isWarn ? '#FEF3C7' : '#DCFCE7'); let badgeColor = isCrit ? '#9F1239' : (isWarn ? '#92400E' : '#166534'); let badgeText = isCrit ? '⚠️ بحرانی (فاصله زیاد از تارگت)' : (isWarn ? '⚡ نیازمند توجه' : '✅ در مسیر تارگت'); const rName = room.name || room.room_name || 'اتاق VIP'; const rCat = room.category || room.genre || 'سینما فرار / ترس'; const rBooked = room.booked !== undefined ? room.booked : (room.booked_slots || 0); const rTarget = room.monthly_target !== undefined ? room.monthly_target : (room.target_slots || 0); const rPct = room.achievement_pct !== undefined ? room.achievement_pct : (room.completion_pct || 0); const rPrice = room.price_per_slot || (room.ticket_price_toman ? room.ticket_price_toman.toLocaleString('fa-IR') + ' تومان' : '۱,۶۰۰,۰۰۰ تومان'); const rAction = room.suggested_action || room.suggested_rescue_action || 'اجرای سناریو و ریلز تبلیغاتی'; return `
${rName}
${rCat}
${badgeText}
رزرو شده: ${rBooked} از ${rTarget} سانس ${rPct}%
💡 اکشن فوری سوشال: ${rAction}
قیمت هر سانس: ${rPrice}
`; }).join('')}
""" # Replace in html if old_vip_map in html: html = html.replace(old_vip_map, new_vip_map) print("Directly replaced VIP card map!") else: # Fuzzy replace start_v = html.find('') end_v = html.find('') if start_v != -1 and end_v != -1: sec1_block = html[start_v:end_v] # Replace the mapping re_vip = re.sub(r'\$\{data\.vip_rooms\.map[\s\S]*?\}\.join\(\'\'\)\}', new_vip_map.strip(), sec1_block) html = html[:start_v] + re_vip + html[end_v:] print("Replaced VIP section with regex!") with open('/workspace/live_marketing_index.html', 'w', encoding='utf-8') as f: f.write(html) print("Saved updated live_marketing_index.html with bulletproof VIP cards!")