06/01 Optimize codes

This commit is contained in:
2026-06-01 17:07:00 -04:00
parent 25b15d8432
commit 4406d9734c
7 changed files with 231 additions and 10 deletions
+20 -3
View File
@@ -226,14 +226,30 @@ def sync_confirm():
parsed.append(r)
imported, skipped = import_transactions(parsed, ta)
flash(f'Imported {imported} transaction(s). Skipped {skipped} duplicate(s).', 'success')
flash(f'Imported {imported} transaction(s) from {ta.account_name}. '
f'Skipped {skipped} duplicate(s).', 'success')
# Advance the sync queue if this came from a "Sync All" run
from flask import session as flask_session
queue = flask_session.pop('teller_sync_queue', [])
if queue:
next_id = queue[0]
flask_session['teller_sync_queue'] = queue[1:]
flash(f'{len(queue)} account(s) remaining in sync queue.', 'info')
return redirect(url_for('teller.sync_preview_view', teller_account_id=next_id))
return redirect(url_for('transactions.index'))
@teller_bp.route('/sync/all', methods=['POST'])
@login_required
def sync_all():
"""Sync all mapped accounts — redirects to first account's preview."""
"""
Queue all mapped accounts for sequential sync.
Stores the full list in session, then redirects to the first account's preview.
After each confirm the queue advances automatically.
"""
from flask import session as flask_session
enrollments = TellerEnrollment.query.filter_by(is_active=True).all()
mapped = []
for e in enrollments:
@@ -245,7 +261,8 @@ def sync_all():
flash('No accounts mapped for sync.', 'warning')
return redirect(url_for('teller.index'))
# For simplicity, sync first account; user can chain through others
# Store the full queue; first item will be previewed immediately
flask_session['teller_sync_queue'] = [ta.id for ta in mapped[1:]]
return redirect(url_for('teller.sync_preview_view', teller_account_id=mapped[0].id))