mirror of
https://github.com/escalante29/WealthySmart.git
synced 2026-07-17 10:08:46 +02:00
Constraint and query pass: FK delete rules, grouped queries, tiebreakers
- FK rules via migration 7884505b16b3 (verified on dev with a rolled- back probe): transactions/recurring items SET NULL on category delete (this also fixes the 500 that DELETE /categories raised for in-use categories), water readings CASCADE with their receipt. Models declare ondelete to stay in sync. (ARCH-09, BE-11) - compute_actuals_by_source: 3 grouped queries replace 10 single- aggregate round-trips; behavior pinned by the existing cycle suite. (BE-21) - compute_cc_by_category prefetches category names (ARCH-15); agent pension latest-per-fund resolved in SQL (BE-04); municipal water consumption batched into one grouped query (BE-05). - Deterministic pagination: date DESC, id DESC on all transaction listings. (ARCH-12) - New agent-tool tests (session binding, JSON-safe output, batched queries): 64 tests green. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -93,7 +93,7 @@ def list_transactions(
|
||||
Transaction.date >= datetime.fromisoformat(start_date),
|
||||
Transaction.date < datetime.fromisoformat(end_date),
|
||||
)
|
||||
query = query.order_by(col(Transaction.date).desc()).offset(offset).limit(limit)
|
||||
query = query.order_by(col(Transaction.date).desc(), col(Transaction.id).desc()).offset(offset).limit(limit)
|
||||
return session.exec(query).all()
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@ def recent_transactions(
|
||||
query = (
|
||||
select(Transaction)
|
||||
.where(Transaction.source == TransactionSource.CREDIT_CARD)
|
||||
.order_by(col(Transaction.date).desc())
|
||||
.order_by(col(Transaction.date).desc(), col(Transaction.id).desc())
|
||||
.limit(limit)
|
||||
)
|
||||
return session.exec(query).all()
|
||||
|
||||
Reference in New Issue
Block a user