-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimulate_orders.py
More file actions
29 lines (25 loc) · 941 Bytes
/
Copy pathsimulate_orders.py
File metadata and controls
29 lines (25 loc) · 941 Bytes
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
# simulate_orders.py
import random
import uuid
from datetime import datetime
from faker import Faker
fake = Faker()
REGIONS = ['Northeast', 'Midwest', 'South', 'West']
PRODUCT_IDS = ['SKU-001', 'SKU-002', 'SKU-003', 'SKU-004']
DEVICE_TYPES = ['mobile', 'desktop', 'tablet']
def generate_order():
order = {
"timestamp": datetime.utcnow().isoformat(),
"order_id": f"ORD-{uuid.uuid4().hex[:10]}",
"product_id": random.choice(PRODUCT_IDS),
"user_id": f"USER-{uuid.uuid4().hex[:8]}",
"region": random.choice(REGIONS),
"quantity": random.randint(1, 5),
"unit_price": round(random.uniform(10, 100), 2),
"device_type": random.choice(DEVICE_TYPES),
"promo_applied": random.choice([True, False])
}
order["total_price"] = round(order["quantity"] * order["unit_price"], 2)
return order
if __name__ == "__main__":
print(generate_order()) # Just for testing