import db
import json
import random
from datetime import datetime, timedelta

USER_ID = 2
MATERIAL_ID = 1
COUNT = 15

statuses = ['pending', 'processing', 'shipped', 'completed', 'cancelled']

print(f"Creating {COUNT} mock orders for user {USER_ID}...")

for i in range(COUNT):
    status = random.choice(statuses)
    created_at = datetime.now() - timedelta(days=i)
    days_ago = i
    
    query = """
    INSERT INTO orders (
        user_id, material_id, first_name, last_name, phone, email, 
        shipping_address, status, estimated_price, total_price, 
        material_name, material_price, color_name, quantity, created_at
    ) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
    """
    params = (
        USER_ID, MATERIAL_ID, "Test", f"User {i}", "123456789", "user@radionica3d.com",
        f"Mock Street {i}, City", status, 10.0 + i, 12.0 + i,
        "PLA", 5.0, "White", 1, created_at
    )
    db.execute_commit(query, params)

print("Done creating mock orders.")
