fix: 增量脚本日志去重 + index_daily 空表自动初始化

This commit is contained in:
2026-08-15 10:33:08 +08:00
parent c5fda08b08
commit bcf721448d
+6
View File
@@ -38,6 +38,7 @@ from importer import (
) )
logger = logging.getLogger("incremental") logger = logging.getLogger("incremental")
logger.propagate = False
if not logger.handlers: if not logger.handlers:
h = logging.StreamHandler() h = logging.StreamHandler()
h.setFormatter(logging.Formatter("%(asctime)s [%(levelname)s] %(message)s")) h.setFormatter(logging.Formatter("%(asctime)s [%(levelname)s] %(message)s"))
@@ -109,6 +110,11 @@ def run_daily(end_date, dry_run, limit):
]: ]:
max_d = get_max_date(conn, table, date_col) max_d = get_max_date(conn, table, date_col)
if max_d is None: if max_d is None:
if table == "index_daily":
logger.warning(" index_daily: 表为空,自动全量初始化(6个指数,很快)")
if not dry_run:
import_index_daily(start_date=None, end_date=end_date)
else:
logger.warning(f" {table}: 表为空,请先执行全量导入 (full_import)") logger.warning(f" {table}: 表为空,请先执行全量导入 (full_import)")
continue continue
start = (max_d + timedelta(days=1)).strftime("%Y-%m-%d") start = (max_d + timedelta(days=1)).strftime("%Y-%m-%d")