Code Room
Code reviewMedium
Question
Review this Python keyset-pagination helper that computes has_more.
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.
Learn the concepts
@app.route('/posts')def list_posts(): limit = int(request.args.get('limit', 20)) after = request.args.get('after_id') q = Post.query.order_by(Post.id.asc()) if after: q = q.filter(Post.id > after) rows = q.limit(limit).all() has_more = len(rows) == limit next_id = rows[-1].id if rows else None return jsonify({'posts': [p.dict() for p in rows], 'next_id': next_id, 'has_more': has_more})Run or narrate your approach, then ask the coach.