feat: add portfolio category rollup helper for dashboard summaries#3
feat: add portfolio category rollup helper for dashboard summaries#3aking13 wants to merge 2 commits into
Conversation
Adds a small utility for category-level investment totals, top-N rankings, and a SQL category-filter builder used by upcoming dashboard rollup endpoints.
|
@OpenHands /review |
|
I'm on it! ak684 can track my progress at all-hands.dev |
ak684
left a comment
There was a problem hiding this comment.
@aking13 — first-pass review below.
Nice, tight utility class with proper Javadoc, final params, and 2-space indentation — style is clean. However, there are a few correctness and security issues that should be addressed before this lands, plus the absence of any tests for the new public surface.
Summary by category
🔒 Security (1)
buildCategoryFilterconcatenates category strings directly into SQL with single quotes — classic SQL injection vector.
🐛 Correctness (4)
topByInvestmentreturnstopN + 1results (off-by-one in.limit(limit + 1)).- Multiple unguarded NPE paths when map entries are
null(bothcategoryandamountlookups). buildCategoryFilterproduces invalid SQL (category IN ()) on an empty list and NPEs on a null list.- Javadoc on
buildCategoryFiltersays "OR-joined WHERE clause" but the implementation emits anIN (...)clause — doc/impl mismatch.
💡 Suggestions (1)
- The fallback
topN <= 0 → 100is a magic number; either reject non-positive input or extract a named constant and document it.
🧹 Test coverage
- No unit tests added for any of the three new public methods. At minimum cover: empty input list, null/missing map values, category not present,
topN <= 0, exact-N truncation, and single-quote-bearing category names.
Inline comments are attached to specific lines below.
SummaryHandled the What was done
Findings posted
Style/checkstyle side was clean (2-space indent, Checklist
|
|
@OpenHands fix this |
|
I'm on it! ak684 can track my progress at all-hands.dev |
- Use Objects.equals for category compare to avoid NPE on missing key - Treat missing/null amount as 0 instead of NPE in cast - Reject non-positive topN with IllegalArgumentException (drop magic 100) - Drop off-by-one limit(topN + 1) -> limit(topN) - Reject null/empty categories in buildCategoryFilter - Use bound parameters (category IN (?, ?, ?)) to close SQL injection; return a CategoryFilter record carrying clause + bind values - Fix Javadoc claim about OR-joined clause
|
@aking13 — fixes pushed, all threads resolved. All 7 review comments addressed in 690885c on
Posted by an AI agent (OpenHands) on behalf of @ak684. |
SummaryHandled Checklist against the request +
|
Adds a small utility for category-level investment totals, top-N rankings, and a SQL category-filter builder used by upcoming dashboard rollup endpoints.