feat(api): implement GET /bounties/:id bounty detail#92
feat(api): implement GET /bounties/:id bounty detail#92automaton365-sys wants to merge 1 commit into
Conversation
🟡 AI Code Review ResultsStatus: Review Recommended 🟡 Merge Score: 80/100🟡 Recommendation: The PR correctly implements the feature with good tests. However, it contains a notable performance inefficiency in how it counts applications. A suggested optimization using a database 💡 Code Suggestions (1)🟡 Medium Priority (1)
💭 Reasoning: Using a dedicated SQL Suggested Code: const [[{ count: applicationCount }], creator, assignee] = await Promise.all([
db.select({ count: sql<number>`cast(count(*) as int)` }).from(applications).where(eq(applications.bountyId, bounty.id)),
db.query.users.findFirst({
where: eq(users.id, bounty.creatorId),
columns: { username: true, avatarUrl: true },
}),
bounty.assigneeId
? db.query.users.findFirst({
where: eq(users.id, bounty.assigneeId),
columns: { username: true, avatarUrl: true },
})
: Promise.resolve(null),
]);
return c.json({
...bounty,
application_count: applicationCount,
creator: creator
? {
username: creator.username,
avatar_url: creator.avatarUrl,
}
: null,
assignee: assignee
? {
username: assignee.username,
avatar_url: assignee.avatarUrl,
}
: null,
});📊 Review Metadata
|
There was a problem hiding this comment.
End goal
The GET /bounties/:id endpoint returns complete bounty detail including creator info, application count, assignee info when assigned, and current status, with proper handling for missing bounties.
✅ Acceptance criteria met (all 7 met)
- C1 — GET /bounties/:id returns the full bounty details for an existing bounty.
- C2 — The response includes creator info containing username and avatar.
- C3 — The response includes the application count for the bounty.
- C4 — The response includes assignee info (e.g., username and avatar) when the bounty is assigned.
- C5 — The response includes the bounty's current status.
- C6 — The endpoint returns a 404 when the requested bounty does not exist.
- C7 — Tests cover the successful response shape and the 404-missing-bounty case.
The endpoint returns full bounty details enriched with creator info, assignee info (when assigned), application count, and status, and returns 404 for missing bounties. Tests cover both the success shape and the 404 case. All criteria are satisfied.
Implements bounty detail endpoint enhancements requested in #21.\n\n### What changed\n- Updated to return:\n - full bounty details\n - info (, )\n - \n - info if assigned (, )\n- Added tests in for:\n - successful response shape\n - 404 when bounty is missing\n\n### Notes\n- Followed existing route/test style and DB query conventions.\n\nFixes #21\n/claim #21