Skip to content

feat(api): implement GET /bounties/:id bounty detail#92

Open
automaton365-sys wants to merge 1 commit intodevasignhq:mainfrom
automaton365-sys:feat/bounty-detail-endpoint
Open

feat(api): implement GET /bounties/:id bounty detail#92
automaton365-sys wants to merge 1 commit intodevasignhq:mainfrom
automaton365-sys:feat/bounty-detail-endpoint

Conversation

@automaton365-sys
Copy link

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

@devasign-app
Copy link

devasign-app bot commented Mar 3, 2026

🟡 AI Code Review Results

Status: Review Recommended
Confidence: 100%


🟡 Merge Score: 80/100

🟡 ████████████████░░░░ 80%

Recommendation: ⚠️ This PR is mostly good but could benefit from some improvements before merging.

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 COUNT query is provided to address this before merging.

💡 Code Suggestions (1)

🟡 Medium Priority (1)

  1. packages/api/src/routes/bounties.ts (Line 141)
    ⚡ The current implementation fetches all application records for a bounty just to count them. This is inefficient and can cause performance issues for bounties with many applications, as it transfers all record IDs to the application server just for a count.

💭 Reasoning: Using a dedicated SQL COUNT aggregate query allows the database to perform the counting operation itself. This is significantly more performant as it reduces data transfer over the network to a single number and lowers memory consumption on the application server.

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
  • Processing Time: 106s
  • Analysis Date: 3/3/2026, 7:58:03 PM

🤖 This review was generated by AI. While we strive for accuracy, please use your judgment when applying suggestions.

💬 Questions about this review? Open an issue or contact support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant