-- Mixed workload: 70% GET, 30% POST
local counter = 0

request = function()
    counter = counter + 1
    
    -- 70% GET requests
    if counter % 10 <= 7 then
        -- Alternate between getting all products and health check
        if counter % 4 == 0 then
            return wrk.format("GET", "/api/v1/health")
        else
            local page = math.random(1, 5)
            return wrk.format("GET", "/api/v1/products?page=" .. page .. "&per_page=10")
        end
    else
        -- 30% POST requests
        local body = string.format('{"name":"Mixed Workload Product %d","description":"Product from mixed workload test","price":%f,"category":"Mixed","stock_quantity":%d}',
            counter, 
            math.random(10, 500) + math.random(),
            math.random(1, 200)
        )
        
        wrk.headers["Content-Type"] = "application/json"
        return wrk.format("POST", "/api/v1/products", nil, body)
    end
end