Open-source personal finance manager. Self-hosted, privacy-first.
feat: raise Category Trends cap to top 11 + Other (#122)
Gabriel Cosme Barbosad81b9acb3244
diff --git a/backend/app/services/report_service.py b/backend/app/services/report_service.pyindex f44d8060..2abe054d 100644--- a/backend/app/services/report_service.py+++ b/backend/app/services/report_service.py@@ -27,6 +27,8 @@ from app.schemas.report import ()from app.services.dashboard_service import _get_open_accounts, _account_balance_at+CATEGORY_TREND_TOP_N = 11+async def _asset_value_at(session: AsyncSession, user_id: uuid.UUID, cutoff: date,@@ -655,8 +657,8 @@ async def get_income_expenses_report((k, v) for (k, g), v in cat_trend_map.items() if g == group]group_items.sort(key=lambda x: x[1]["total"], reverse=True)- top = group_items[:6]- rest = group_items[6:]+ top = group_items[:CATEGORY_TREND_TOP_N]+ rest = group_items[CATEGORY_TREND_TOP_N:]for cat_key, info in top:series = [diff --git a/frontend/src/pages/reports.tsx b/frontend/src/pages/reports.tsxindex e6225fd9..0ac91ba6 100644--- a/frontend/src/pages/reports.tsx+++ b/frontend/src/pages/reports.tsx@@ -38,6 +38,8 @@ function formatCompact(value: number, currency = 'USD', locale = 'en-US') {}).format(value)}+const COMPOSITION_TOP_N = 6+const RANGE_OPTIONS = [{ key: '6m', months: 6 },{ key: '1y', months: 12 },@@ -157,10 +159,10 @@ export default function ReportsPage() {items = composition.filter((c) => c.group === 'expenses')}- // Sort descending, take top 6, bucket the rest into "Other"+ // Sort descending, take top N, bucket the rest into "Other"const sorted = [...items].sort((a, b) => b.value - a.value)- const top = sorted.slice(0, 6)- const rest = sorted.slice(6)+ const top = sorted.slice(0, COMPOSITION_TOP_N)+ const rest = sorted.slice(COMPOSITION_TOP_N)const otherValue = rest.reduce((sum, c) => sum + c.value, 0)const result = top.map((c) => ({