Code Room
Vibe codingHard
Question
An AI wrote this Django aggregation that powers an internal analytics dashboard across a multi-tenant fleet. It's correct but reads the entire events table into memory and N+1s on the project FK; on the largest tenant the worker OOMs. Refactor it to scale.
def usage_report(org_id): events = Event.objects.filter(org_id=org_id) # can be tens of millions totals = {} for e in events: key = e.project.name # FK lookup per row totals.setdefault(key, 0) totals[key] += e.cost_cents return totalsWhat 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.
Learn the concepts
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.