Code RoomKeyset pagination has_more logic
MediumPrep Room Coding #1782

Keyset pagination has_more logic

Code reviewNetworking & APIsMid–Senior~22 min

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.

0:00 of about 22 min
Mark a line and say what kind of problem it is.0 findings
1@app.route('/posts')
2def list_posts():
3 limit = int(request.args.get('limit', 20))
4 after = request.args.get('after_id')
5 q = Post.query.order_by(Post.id.asc())
6 if after:
7 q = q.filter(Post.id > after)
8 rows = q.limit(limit).all()
9 has_more = len(rows) == limit
10 next_id = rows[-1].id if rows else None
11 return jsonify({'posts': [p.dict() for p in rows],
12 'next_id': next_id, 'has_more': has_more})
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.