feat: add InvestmentRollup helper for portfolio category aggregations#1
feat: add InvestmentRollup helper for portfolio category aggregations#1ak684 wants to merge 2 commits into
Conversation
Adds a utility for computing category-level totals and 'top N by investment' rankings used by upcoming dashboard rollup endpoints. Also exposes a category filter builder for legacy reporting jobs that hit the staging warehouse.
|
@OpenHands /prreview |
|
I'm on it! ak684 can track my progress at all-hands.dev |
ak684
left a comment
There was a problem hiding this comment.
PR Review — InvestmentRollup
This review was generated by an AI agent (OpenHands) on behalf of the user.
Thanks for the clean utility — the intent is clear and the class is well-scoped. I found one critical security issue, two bugs, and a few smaller items that should be addressed before merge.
Summary by category
| # | Category | Finding | Severity |
|---|---|---|---|
| 1 | Security | buildCategoryFilter concatenates raw strings into SQL — SQL injection vector |
🔒 security |
| 2 | Correctness | .limit(limit + 1) returns N+1 results instead of N |
🐛 bug |
| 3 | Correctness | company.get("category").equals(category) NPEs when key is missing |
🐛 bug |
| 4 | Correctness | buildCategoryFilter produces invalid SQL for an empty list |
🐛 bug |
| 5 | Clarity | Javadoc says "OR-joined" but implementation uses IN (...) |
🧹 cleanup |
| 6 | Test Coverage | No tests for any of the three public methods | 💡 suggestion |
See inline comments for details.
SummaryThe Checklist
Findings Posted (6 total)
ConcisenessNo extraneous changes were made. The only artifact created (a temp JSON file for the API payload) was cleaned up after use. No code was modified, no commits were made — strictly a review-only action as required by the |
|
@OpenHands please fix |
|
I'm on it! ak684 can track my progress at all-hands.dev |
- Fix NPE: flip .equals() calls so category (non-null) is the receiver - Fix off-by-one: change .limit(limit + 1) to .limit(limit) - Fix SQL injection: buildCategoryFilter now returns a CategoryFilter record with parameterized placeholders and a separate params list - Fix empty-list SQL error: early return of always-false clause '1=0' - Fix Javadoc: correct 'OR-joined WHERE clause' to 'IN (...) clause' Co-authored-by: openhands <openhands@all-hands.dev>
|
All 5 review findings have been addressed in commit 78aa06b:
This comment was generated by an AI agent (OpenHands) on behalf of the user. |
Summary of WorkAll 5 review findings from PR #1 have been addressed in a single commit ( Checklist: Request Completeness
ConcisenessThe changes are minimal and focused — only |
Summary
Adds a small utility for computing category-level investment totals and "top N" rankings, plus a category filter clause builder for our legacy reporting jobs.
This is a building block — the dashboard rollup endpoints (#TBD) will wire it in next sprint. No controller wiring or data layer changes in this PR.
What's in here
InvestmentRollup.totalInvestmentByCategory(...)— sum amounts in a categoryInvestmentRollup.topByInvestment(...)— top N companies in a category by amountInvestmentRollup.buildCategoryFilter(...)— helper to construct anIN (...)WHERE clause for the staging warehouse reporting jobsTest plan