mirror of
https://ghfast.top/https://github.com/aeroxw/tick-stock-panel.git
synced 2026-09-12 17:54:15 +08:00
fix(ext-pull): 定时拉取不再清空策略结果缓存
扩展表 PullScheduler 每轮成功写入都会经 invalidate_ext_caches 销毁 strategy_cache, 策略页随之下一次轮询整页空白, 且前端会话级防重入 (runAllDateRef) 不会自动补跑, 小服务器上全量重算需分钟级 → 页面长期黑屏。 例行数据刷新改为只失效扩展帧缓存与注册同步状态 (下次策略运行自然 读到新值); 手动上传/配置变更保持全清 (触发下次全量重算) 旧行为。 keep_strategy_cache 沿 fetch_and_ingest → rows_to_parquet → write_ext_parquet → invalidate_ext_caches 显式传递。
This commit is contained in:
@@ -257,10 +257,13 @@ async def fetch_and_ingest(
|
||||
config: ExtConfig,
|
||||
data_dir,
|
||||
target_date: date | None = None,
|
||||
*,
|
||||
keep_strategy_cache: bool = False,
|
||||
) -> tuple[int, str]:
|
||||
"""执行一次拉取: 请求外部 API → 解析响应 → 写入 Parquet。
|
||||
|
||||
target_date 默认当日; 历史回补传入目标日期 (写入对应分区)。
|
||||
keep_strategy_cache=True 由定时拉取循环传入: 例行刷新不清策略结果缓存。
|
||||
Returns:
|
||||
(rows_written, date_str)
|
||||
"""
|
||||
@@ -269,7 +272,10 @@ async def fetch_and_ingest(
|
||||
rows = await fetch_rows_for_date(config, day)
|
||||
if not rows:
|
||||
raise ValueError("提取到的行数为 0")
|
||||
n = rows_to_parquet(rows, config, data_dir, snapshot_date=day)
|
||||
n = rows_to_parquet(
|
||||
rows, config, data_dir, snapshot_date=day,
|
||||
keep_strategy_cache=keep_strategy_cache,
|
||||
)
|
||||
return n, day.isoformat()
|
||||
|
||||
|
||||
@@ -498,7 +504,11 @@ class PullScheduler:
|
||||
|
||||
# 先执行一次 (启用即拉取, 让用户立刻看到生效)
|
||||
try:
|
||||
n, d = await fetch_and_ingest(fresh, self._data_dir)
|
||||
# 例行定时刷新: 不清策略结果缓存 (见 invalidate_ext_caches),
|
||||
# 否则策略页每轮拉取后整页空白, 直到下次全量重算完成。
|
||||
n, d = await fetch_and_ingest(
|
||||
fresh, self._data_dir, keep_strategy_cache=True
|
||||
)
|
||||
fresh.pull.last_run = datetime.now(timezone.utc).isoformat()
|
||||
fresh.pull.last_status = "success"
|
||||
fresh.pull.last_message = f"{n} rows @ {d}"
|
||||
|
||||
Reference in New Issue
Block a user