Skip to content

feat: add weekly financial summary endpoint#1075

Open
jimes0813 wants to merge 2 commits into
rohitdash08:mainfrom
jimes0813:main
Open

feat: add weekly financial summary endpoint#1075
jimes0813 wants to merge 2 commits into
rohitdash08:mainfrom
jimes0813:main

Conversation

@jimes0813
Copy link
Copy Markdown

@jimes0813 jimes0813 commented May 24, 2026

Summary

Weekly financial summary endpoint with AI + heuristic dual-path.

Changes (v2 — French Code Review Integration)

Security

  • API key removed from client headers, server-side only
  • urllib replaced with httpx (explicit SSL verify=True)
  • Broad except Exception split into 4 precise exception types

Performance

  • N+1 queries (8/req) → single CASE WHEN aggregation
  • Date boundary fix: spent_at <= week_end → spent_at < next_day
  • Response caching via Flask-Caching (1h TTL)
  • Rate limiting via Flask-Limiter (20/min per user)

Quality

  • 11 unit tests (up from 4), parametrized exceptions
  • DB savepoint isolation fixture
  • ref_date validation (future/malformed → HTTP 400)
  • Locale-aware AI responses (en/zh/es via Accept-Language)
  • WEEKLY_PERSONA in config, locale-aware persona builder

Files

File Lines
app/services/weekly_summary.py 409
app/routes/weekly_summary.py 108
tests/test_weekly_summary.py 317 (11 tests)
app/extensions.py 36

Claim

/claim #121

Closes #121

- New GET /insights/weekly-summary endpoint
- AI-powered (Gemini) weekly analytics with heuristic fallback
- Week-over-week spend comparison, category breakdown, daily trends
- Full test suite (4 tests covering heuristic, AI, fallback, categories)
- Includes /claim rohitdash08#121 in PR body for bounty

Closes rohitdash08#121
Merges improvements from code review (PLA/France):

Security:
- SEC-1: API key removed from client headers, server-side only
- SEC-2: urllib replaced with httpx (explicit SSL verify=True)
- SEC-3: Broad except Exception split into 4 precise types

Performance:
- N+1 queries (8/req) → single CASE WHEN aggregation
- Date boundary fix: spent_at <= week_end → spent_at < next_day
- Response caching (Flask-Caching, 1h TTL)
- Rate limiting (Flask-Limiter, 20/min)

Quality:
- 11 tests (up from 4), parametrized exceptions
- DB savepoint isolation fixture
- ref_date validation (future/malformed → 400)
- Locale-aware AI responses (en/zh/es via Accept-Language)
- WEEKLY_PERSONA in config, locale-aware persona builder

Closes rohitdash08#121
/claim rohitdash08#121
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Smart digest with weekly financial summary

1 participant