Add BQL-optimized get_unsettled_entries_bql method

Replace inefficient approach that fetched ALL journal entries with
targeted BQL queries that:
- Filter by account pattern and tags in the database
- Use weight column for SATS amounts (no string parsing)
- Query only expense/receivable entries for the specific user

This significantly reduces data transfer and processing overhead.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
padreug 2025-12-15 01:08:38 +01:00
parent 55df2b36e0
commit 048d19f90b
2 changed files with 146 additions and 1 deletions

View file

@ -2264,7 +2264,7 @@ async def api_get_unsettled_entries(
)
fava = get_fava_client()
unsettled = await fava.get_unsettled_entries(user_id, entry_type)
unsettled = await fava.get_unsettled_entries_bql(user_id, entry_type)
# Calculate totals
total_fiat = sum(e.get("fiat_amount", 0) for e in unsettled)