feat: Buchungs-Pagination, Inbox-Scan-Button, Grafana-Direktansteuerung, UI-Feinschliff
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -19,10 +19,12 @@ from app.routers.planning import list_planned as _list_planned
|
||||
from app.routers.planning import list_recurring as _list_recurring
|
||||
from app.routers.planning import recurring_suggestions as _recurring_suggestions
|
||||
from app.routers.scenarios import list_scenarios as _list_scenarios
|
||||
from app.routers.transactions import list_transactions
|
||||
from app.routers.transactions import count_transactions, list_transactions
|
||||
from app.services.balances import account_balance, total_balance
|
||||
from app.version import get_version
|
||||
|
||||
PAGE_SIZE = 50
|
||||
|
||||
templates = Jinja2Templates(directory="app/templates")
|
||||
templates.env.globals["app_version"] = get_version()
|
||||
router = APIRouter()
|
||||
@@ -81,8 +83,21 @@ def buchungen(
|
||||
category_id: int | None = None,
|
||||
q: str | None = None,
|
||||
status: str = "confirmed",
|
||||
page: int = 1,
|
||||
session: Session = Depends(get_session),
|
||||
):
|
||||
page = max(1, page)
|
||||
total = count_transactions(
|
||||
account_id=account_id,
|
||||
date_from=date_from,
|
||||
date_to=date_to,
|
||||
category_id=category_id,
|
||||
q=q,
|
||||
status=status,
|
||||
session=session,
|
||||
)
|
||||
total_pages = max(1, -(-total // PAGE_SIZE)) # ceil division
|
||||
page = min(page, total_pages)
|
||||
txs = list_transactions(
|
||||
account_id=account_id,
|
||||
date_from=date_from,
|
||||
@@ -90,8 +105,8 @@ def buchungen(
|
||||
category_id=category_id,
|
||||
q=q,
|
||||
status=status,
|
||||
limit=200,
|
||||
offset=0,
|
||||
limit=PAGE_SIZE,
|
||||
offset=(page - 1) * PAGE_SIZE,
|
||||
session=session,
|
||||
)
|
||||
accounts = session.execute(select(Account)).scalars().all()
|
||||
@@ -108,6 +123,8 @@ def buchungen(
|
||||
"q": q or "",
|
||||
"status": status,
|
||||
},
|
||||
"page": page,
|
||||
"total_pages": total_pages,
|
||||
})
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user