06/02 Optimize app 2

This commit is contained in:
2026-06-02 16:34:16 -04:00
parent de948156b9
commit c9eb1b89fc
6 changed files with 131 additions and 7 deletions
+25
View File
@@ -217,3 +217,28 @@ def manual_snapshot():
snap = take_net_worth_snapshot()
flash(f'Net worth snapshot saved: {snap.snapshot_date.strftime("%B %d, %Y")}', 'success')
return redirect(url_for('reports.index'))
@reports_bp.route('/rebuild-snapshot', methods=['POST'])
@login_required
def rebuild_snapshot():
"""Recalculate all balances then replace today's snapshot with fresh data."""
from app.services.account_service import recalc_all
from app.models.net_worth_snapshot import NetWorthSnapshot
recalc_all()
# Delete today's snapshot so take_net_worth_snapshot() creates a fresh one
today = date.today()
existing = NetWorthSnapshot.query.filter_by(snapshot_date=today).first()
if existing:
from app.extensions import db
db.session.delete(existing)
db.session.commit()
snap = take_net_worth_snapshot()
flash(
f'Balances recalculated and snapshot rebuilt for {snap.snapshot_date.strftime("%B %d, %Y")}.',
'success'
)
return redirect(url_for('reports.index'))