fix: reload sentiment cycle history after backfill

backfillData() only refreshed system settings after a successful backfill,
leaving state.sentimentHistory/sentimentHistoryKey populated with the stale
pre-backfill cache, so an already-open sentiment cycle page kept showing the
old one-day history.

After a successful backfill, clear both cache fields and, when the sentiment
cycle view is active, force loadSentimentHistory(true) so the history renders
immediately. Add a frontend contract test covering the refresh path.

Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
MS-01-Codex
2026-08-18 21:52:15 +08:00
co-authored by multica-agent
parent 71b3ab1d5d
commit d561de06ec
3 changed files with 16 additions and 2 deletions
+2 -2
View File
@@ -541,8 +541,8 @@
},
{
"path": "frontend/shared/admin.js",
"bytes": 14386,
"lines": 265
"bytes": 14556,
"lines": 270
},
{
"path": "backend/features/heaven/market_context.py",
+5
View File
@@ -8,6 +8,11 @@ async function backfillData() {
end_date: document.querySelector("#backfillEnd").value,
});
showToast(`历史回补完成,共处理 ${payload.results.length} 个工作日`);
state.sentimentHistory = null;
state.sentimentHistoryKey = "";
if (state.activeView === "sentimentCycleView") {
await loadSentimentHistory(true);
}
await openAdminSettings(true);
} catch (error) {
showToast(error.message);
+9
View File
@@ -166,6 +166,15 @@ class FrontendContractTests(unittest.TestCase):
self.assertIn('id="accountDropdown"', self.html)
self.assertIn('id="settingsButton"', self.html)
def test_backfill_clears_sentiment_cache_and_reloads_sentiment_view(self):
start = self.script.index("async function backfillData")
end = self.script.index("async function openAdminSettings", start)
backfill = self.script[start:end]
self.assertIn("state.sentimentHistory = null;", backfill)
self.assertIn('state.sentimentHistoryKey = "";', backfill)
self.assertIn('if (state.activeView === "sentimentCycleView")', backfill)
self.assertIn("await loadSentimentHistory(true);", backfill)
def test_screener_uses_progressive_strategy_editor(self):
for step in ("regime", "strategy", "run", "result"):
self.assertIn(f'data-screener-step="{step}"', self.html)