Spaces:
Sleeping
Sleeping
File size: 9,525 Bytes
c061318 |
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 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
#!/usr/bin/env python3
"""
Mock Data Service
Provides sample customer data for testing when external backend is not available
"""
import json
import random
from datetime import datetime, timedelta
from typing import List, Dict, Any
class MockDataService:
def __init__(self):
self.sample_properties = [
{
"propertyId": 1,
"propertyName": "Luxury Villa in Palm Jumeirah",
"propertyTypeName": "Villa",
"price": 15000000,
"viewCount": 15,
"totalDuration": 4500,
"lastViewedAt": "2024-01-15T10:30:00Z",
"location": "Palm Jumeirah",
"bedrooms": 5,
"bathrooms": 6,
"area": 8500,
"features": ["Private Pool", "Garden", "Gym", "Security"]
},
{
"propertyId": 2,
"propertyName": "Modern Apartment in Downtown",
"propertyTypeName": "Apartment",
"price": 3500000,
"viewCount": 8,
"totalDuration": 2800,
"lastViewedAt": "2024-01-14T14:20:00Z",
"location": "Downtown Dubai",
"bedrooms": 2,
"bathrooms": 2,
"area": 1200,
"features": ["Balcony", "Gym", "Pool", "Parking"]
},
{
"propertyId": 3,
"propertyName": "Beachfront Penthouse",
"propertyTypeName": "Penthouse",
"price": 25000000,
"viewCount": 12,
"totalDuration": 5200,
"lastViewedAt": "2024-01-13T16:45:00Z",
"location": "JBR",
"bedrooms": 4,
"bathrooms": 5,
"area": 3200,
"features": ["Beach Access", "Private Terrace", "Concierge", "Spa"]
},
{
"propertyId": 4,
"propertyName": "Family Villa in Emirates Hills",
"propertyTypeName": "Villa",
"price": 18000000,
"viewCount": 6,
"totalDuration": 3800,
"lastViewedAt": "2024-01-12T11:15:00Z",
"location": "Emirates Hills",
"bedrooms": 6,
"bathrooms": 7,
"area": 9500,
"features": ["Garden", "Pool", "Gym", "Staff Quarters"]
},
{
"propertyId": 5,
"propertyName": "Investment Apartment",
"propertyTypeName": "Apartment",
"price": 2200000,
"viewCount": 4,
"totalDuration": 1500,
"lastViewedAt": "2024-01-11T09:30:00Z",
"location": "Dubai Marina",
"bedrooms": 1,
"bathrooms": 1,
"area": 800,
"features": ["Marina View", "Gym", "Pool", "Rental Ready"]
},
{
"propertyId": 6,
"propertyName": "Luxury Townhouse",
"propertyTypeName": "Townhouse",
"price": 8500000,
"viewCount": 10,
"totalDuration": 4200,
"lastViewedAt": "2024-01-10T13:20:00Z",
"location": "Arabian Ranches",
"bedrooms": 4,
"bathrooms": 4,
"area": 2800,
"features": ["Garden", "Pool", "Golf Course", "Community"]
},
{
"propertyId": 7,
"propertyName": "Premium Office Space",
"propertyTypeName": "Office",
"price": 12000000,
"viewCount": 3,
"totalDuration": 1800,
"lastViewedAt": "2024-01-09T15:45:00Z",
"location": "DIFC",
"bedrooms": 0,
"bathrooms": 2,
"area": 5000,
"features": ["Premium Location", "Security", "Parking", "Meeting Rooms"]
},
{
"propertyId": 8,
"propertyName": "Retail Space in Mall",
"propertyTypeName": "Retail",
"price": 8000000,
"viewCount": 2,
"totalDuration": 1200,
"lastViewedAt": "2024-01-08T12:00:00Z",
"location": "Dubai Mall",
"bedrooms": 0,
"bathrooms": 1,
"area": 3000,
"features": ["High Foot Traffic", "Premium Location", "Storage", "Security"]
}
]
def get_customer_data(self, customer_id: int) -> List[Dict[str, Any]]:
"""Get mock customer data based on customer ID"""
# Generate different data based on customer ID
if customer_id == 105:
# High-value customer with luxury preferences
return self.sample_properties[:4] # First 4 properties (luxury)
elif customer_id == 106:
# Mid-range customer
return self.sample_properties[1:5] # Properties 2-5
elif customer_id == 107:
# Investment-focused customer
return [self.sample_properties[4], self.sample_properties[6], self.sample_properties[7]]
elif customer_id == 108:
# Budget-conscious customer
return [self.sample_properties[1], self.sample_properties[4]]
else:
# Random selection for other customer IDs
num_properties = random.randint(2, 6)
return random.sample(self.sample_properties, num_properties)
def get_customer_profile(self, customer_id: int) -> Dict[str, Any]:
"""Get customer profile information"""
profiles = {
105: {
"customerName": "Ahmed Al Mansouri",
"email": "ahmed.mansouri@email.com",
"phone": "+971501234567",
"preferredLocation": "Palm Jumeirah",
"budgetRange": "15M-25M",
"propertyType": "Villa",
"leadSource": "Website",
"lastContact": "2024-01-15T10:30:00Z"
},
106: {
"customerName": "Sarah Johnson",
"email": "sarah.johnson@email.com",
"phone": "+971502345678",
"preferredLocation": "Downtown Dubai",
"budgetRange": "3M-8M",
"propertyType": "Apartment",
"leadSource": "Referral",
"lastContact": "2024-01-14T14:20:00Z"
},
107: {
"customerName": "Mohammed Rahman",
"email": "m.rahman@email.com",
"phone": "+971503456789",
"preferredLocation": "Dubai Marina",
"budgetRange": "2M-15M",
"propertyType": "Mixed",
"leadSource": "Investment Portal",
"lastContact": "2024-01-13T16:45:00Z"
},
108: {
"customerName": "Fatima Hassan",
"email": "fatima.hassan@email.com",
"phone": "+971504567890",
"preferredLocation": "Dubai Marina",
"budgetRange": "2M-4M",
"propertyType": "Apartment",
"leadSource": "Social Media",
"lastContact": "2024-01-12T11:15:00Z"
}
}
return profiles.get(customer_id, {
"customerName": f"Customer {customer_id}",
"email": f"customer{customer_id}@email.com",
"phone": f"+97150{random.randint(1000000, 9999999)}",
"preferredLocation": random.choice(["Dubai Marina", "Downtown Dubai", "Palm Jumeirah", "JBR"]),
"budgetRange": random.choice(["2M-5M", "5M-10M", "10M-20M", "20M+"]),
"propertyType": random.choice(["Apartment", "Villa", "Townhouse", "Mixed"]),
"leadSource": random.choice(["Website", "Referral", "Social Media", "Advertisement"]),
"lastContact": datetime.now().isoformat()
})
def generate_engagement_metrics(self, customer_id: int) -> Dict[str, Any]:
"""Generate engagement metrics for the customer"""
base_engagement = random.randint(30, 90)
# Adjust based on customer ID
if customer_id == 105:
base_engagement = 85 # High engagement
elif customer_id == 106:
base_engagement = 65 # Medium engagement
elif customer_id == 107:
base_engagement = 45 # Lower engagement
elif customer_id == 108:
base_engagement = 55 # Medium-low engagement
return {
"totalViews": random.randint(5, 25),
"totalDuration": random.randint(1800, 7200), # 30 minutes to 2 hours
"engagementScore": base_engagement,
"lastActivity": datetime.now().isoformat(),
"favoriteProperties": random.randint(1, 4),
"searchQueries": random.randint(3, 12),
"emailOpens": random.randint(1, 8),
"websiteVisits": random.randint(2, 15)
}
# Global instance
mock_data_service = MockDataService() |