diff --git a/ft-app/app/collector.py b/ft-app/app/collector.py index 242cc80..2540695 100644 --- a/ft-app/app/collector.py +++ b/ft-app/app/collector.py @@ -5,7 +5,7 @@ from app.database import SessionLocal from app.models import DailyBar, Contract from app.engine.lock_strategy import compute_amp_5d -_progress = {"running": False, "label": "", "done": 0, "total": 0, "finished": False} +_progress = {"running": False, "label": "", "done": 0, "total": 0, "result": 0, "finished": False} _lock = threading.Lock() @@ -78,6 +78,8 @@ def sync_contract_bars_bg(contract_code: str) -> bool: db.flush() _recompute_amp(db, code, from_date=min_date) db.commit() + with _lock: + _progress["result"] = inserted finally: db.close() @@ -132,6 +134,9 @@ def sync_positions_bg(contract_code: str) -> bool: with _lock: _progress["done"] = i + 1 _progress["label"] = f"同步持仓 {code} · {i + 1}/{total_missing} 天" + db.commit() + with _lock: + _progress["result"] = inserted finally: db.close() diff --git a/ft-app/app/templates/admin.html b/ft-app/app/templates/admin.html index 8d05962..660c920 100644 --- a/ft-app/app/templates/admin.html +++ b/ft-app/app/templates/admin.html @@ -69,8 +69,8 @@ 查看 - - + + {% endfor %} @@ -225,8 +225,16 @@ function pollProgress() { clearInterval(syncTimer); syncTimer = null; document.getElementById('sync-progress-bar').style.width = '100%'; - document.getElementById('sync-progress-label').textContent = data.label + ' ✓'; + var resultText = data.result > 0 ? ' · +' + data.result : ''; + document.getElementById('sync-progress-label').textContent = data.label + ' ✓' + resultText; document.getElementById('sync-progress-pct').textContent = ''; + // Remember which product headers are expanded before reload + var expanded = []; + document.querySelectorAll('.product-body').forEach(function(b, i) { + if (b.style.display === 'block') expanded.push(i); + }); + try { sessionStorage.setItem('ft-expanded', JSON.stringify(expanded)); } catch(e) {} + setTimeout(function() { location.reload(); }, 1200); }, delay); } }); @@ -268,5 +276,21 @@ function toggleProduct(header) { } } +// Restore expanded accordion state after reload +(function() { + try { + var expanded = JSON.parse(sessionStorage.getItem('ft-expanded') || '[]'); + var bodies = document.querySelectorAll('.product-body'); + expanded.forEach(function(i) { + if (bodies[i]) { + bodies[i].style.display = 'block'; + var arrow = bodies[i].previousElementSibling.querySelector('.collapse-arrow'); + if (arrow) arrow.style.transform = 'rotate(0deg)'; + } + }); + sessionStorage.removeItem('ft-expanded'); + } catch(e) {} +})(); + {% endblock %} diff --git a/ft-app/data/ft.db b/ft-app/data/ft.db index 07170e4..3dc23af 100644 Binary files a/ft-app/data/ft.db and b/ft-app/data/ft.db differ