Code Room
Vibe codingMediumvc-g096
Subject Ai code reviewLevel Mid–Senior~15 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

An AI assistant wrote this Django view to export every order with its line items to CSV. It works fine in dev. In production the endpoint times out and the worker is OOM-killed.

python
def export_orders(request):    orders = Order.objects.all()    rows = []    for order in orders:        for item in order.items.all():            rows.append([order.id, order.total, item.sku, item.qty])    return csv_response(rows)

Identify both performance problems and rewrite the data access.

What a strong answer looks like

Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it — tests, edge cases, reading critically — and how you’d re-prompt or decompose to get it right.

Describe your solution

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.