Analytics aggregation memory overflow
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.
Implement
usage_report_lines(rows: list[str]) → list[str]Examples
in
[["alpha|100","beta|50","alpha|25"]]out["alpha=125","beta=50"]in
[["a|10","b|10"]]out["a=10","b=10"]in
[[]]out[]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.
0:00 of about 20 min
Vibe & agentic: describe the solution in plain language (or narrate it) and the coach grades your approach.
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.
Run or narrate your approach, then ask the coach.