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'))
+19 -1
View File
@@ -119,11 +119,29 @@ def _category_choices(txn_type='expense'):
@settings_bp.route('/')
@login_required
def index():
from flask import current_app
upcoming = get_upcoming(days=30)
rules = RecurringRule.query.filter_by(is_active=True).order_by(RecurringRule.name).all()
smtp_ok = all([
current_app.config.get('SMTP_HOST'),
current_app.config.get('SMTP_USER'),
current_app.config.get('SMTP_PASSWORD'),
current_app.config.get('ALERT_EMAIL'),
])
return render_template('settings/index.html',
upcoming=upcoming,
rules=rules)
rules=rules,
smtp_ok=smtp_ok,
alert_email=current_app.config.get('ALERT_EMAIL', ''))
@settings_bp.route('/recalc-balances', methods=['POST'])
@login_required
def recalc_balances():
from app.services.account_service import recalc_all
recalc_all()
flash('All account balances recalculated.', 'success')
return redirect(url_for('settings.index'))
@settings_bp.route('/profile', methods=['GET', 'POST'])
+17
View File
@@ -280,6 +280,23 @@ def sync_all():
return redirect(url_for('teller.sync_preview_view', teller_account_id=mapped[0].id))
# ── Full resync (reset last_sync_date so next sync fetches full history) ─────
@teller_bp.route('/resync/<int:teller_account_id>', methods=['POST'])
@login_required
def full_resync(teller_account_id):
ta = db.get_or_404(TellerAccount, teller_account_id)
ta.last_sync_date = None
ta.last_teller_txn_id = None
db.session.commit()
flash(
f'{ta.account_name}: reset to full resync. '
f'Next sync will fetch the last 90 days — duplicates will be skipped automatically.',
'info'
)
return redirect(url_for('teller.index'))
# ── Balance refresh ───────────────────────────────────────────────────────────
@teller_bp.route('/balance/<int:teller_account_id>', methods=['POST'])