feat(api): enrich GET /bounties/:id response#86
feat(api): enrich GET /bounties/:id response#86gavin-openops wants to merge 2 commits intodevasignhq:mainfrom
Conversation
🟢 AI Code Review ResultsStatus: Ready to Merge 🟢 Merge Score: 85/100🟢 Recommendation: ✅ This PR looks great and is ready for merge! The PR successfully enriches the bounty detail endpoint as requested. The implementation is efficient, using Promise.all for concurrent data fetching. However, the code can be improved by using more idiomatic ORM functions and by adding a test case for unassigned bounties to increase robustness. 💡 Code Suggestions (3)🟡 Medium Priority (1)
💭 Reasoning: The current tests only cover bounties with an assignee. Adding a test for an unassigned bounty ensures the conditional logic for fetching the assignee is correct and prevents future regressions where Suggested Code: it('should return null for assignee when bounty is not assigned', async () => {
const bountyId = 'bounty-no-assignee';
vi.mocked(db.query.bounties.findFirst).mockResolvedValue({
id: bountyId,
title: 'Bounty 2',
status: 'open',
creatorId: 'creator-1',
assigneeId: null, // No assignee
} as any);
vi.mocked(db.query.users.findFirst)
.mockResolvedValueOnce({ username: 'creatorUser', avatarUrl: 'https://avatar/creator.png' } as any);
vi.mocked(db.select as any).mockReturnValue({
from: () => ({
where: async () => [{ count: 1 }],
}),
} as any);
const res = await app.request(`/api/bounties/${bountyId}`, {
headers: {
'Authorization': 'Bearer valid.token'
}
});
expect(res.status).toBe(200);
const body = await res.json();
expect(body.id).toBe(bountyId);
expect(body.creator).not.toBeNull();
expect(body.assignee).toBeNull();
expect(body.applicationCount).toBe(1);
});🔵 Low Priority (2)
💭 Reasoning: Using the ORM's built-in functions like Suggested Code: db
.select({ count: count() })
.from(applications)
.where(eq(applications.bountyId, id)),
💭 Reasoning: A more accurate filename improves project organization and makes it easier for developers to locate relevant tests, enhancing overall maintainability. 📊 Review Metadata
|
🔄 Follow-Up AI Code ReviewStatus: Ready to Merge 🟢 Updated Merge Score: 100/100🟢 Recommendation: ✅ This PR looks great and is ready for merge! 📋 Previous Review SummaryThe PR successfully enriches the bounty detail endpoint as requested. The implementation is efficient, using Promise.all for concurrent data fetching. However, the code can be improved by using more idiomatic ORM functions and by adding a test case for unassigned bounties to increase robustness. Excellent work. The feedback from the previous review has been fully addressed. The addition of the test case for bounties without an assignee makes the implementation robust. The code is clean, efficient, and ready for merging. 💡 Code Suggestions✨ Great job! No specific suggestions at this time. 📊 Review Metadata
|
|
I implemented the medium-priority suggestion and pushed an update:
I left the |
Summary
GET /api/bounties/:idwith creator profile data (username + avatar)Why
Implements #21 by returning the additional fields needed by the mobile app detail view.
Testing
npm test -- bounties_list.test.ts(frompackages/api)npm run build(frompackages/api)Closes #21