Code Room
Code reviewHardcr-g477
Subject N plus one queriesLevel Mid–Senior~22 minCommon in Code quality & review interviewsIndustries Software development

Question

Review this Python (SQLAlchemy) lookup for a user’s recent active orders.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.

Talk through your review
Code to reviewpython
def recent_active(session, user_id):    orders = session.query(Order).all()          # load the whole table    result = []    for o in orders:        if o.user_id == user_id and o.status == "active":            if o.created_at >= last_30_days():                result.append(o)    return result
Run or narrate your approach, then ask the coach.