Files
FinDataHub 11d36d1c1e fix(repo): 修正 Scripts 目录索引大小写并补齐未入库脚本
问题
- 索引中该目录记为小写 `scripts/`,工作区实为 `Scripts/`。因 core.ignorecase=true,
  本地 `git diff -- Scripts/bin/x.py` 会**静默返回空**(看似无改动),
  且在大小写敏感环境(Linux CI / Docker 挂载)会检出 `scripts/`,
  与全仓所有 `Scripts/...` 引用不匹配。
- 该目录此前 10 个脚本(check_python_version.py、perf_snapshot.py、
  install_collector_launchd.py、mysql_toggle.sh 等)从未入库,
  而 CI 第 31 行正调用 `Scripts/bin/check_python_version.py --strict` ——
  全新检出必然失败。

改动
- 索引路径统一为 `Scripts/`(工作区文件未移动,仅索引改名)。
- 补齐上述 10 个未跟踪脚本及其测试。

影响
- 修正前索引 35 条(全为小写路径),修正后 45 条。
2026-09-18 22:37:32 +08:00

83 lines
2.7 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
"""
init_rss_sources.py — 初始化 RSS 数据源的 MySQL 表和 source 记录
运行一次即可: python3 init_rss_sources.py
"""
import pymysql
from common import MYSQL_CFG
def init():
conn = pymysql.connect(**MYSQL_CFG)
cur = conn.cursor()
# 1. 插入 news_sources 记录(如不存在)
sources = [
("东方财富快讯", "eastmoney", "东方财富 7×24 快讯(RSS)"),
("同花顺快讯", "10jqka", "同花顺 7×24 快讯(RSS)"),
("雪球动态", "xueqiu", "雪球用户动态(RSS)"),
]
for name, code, desc in sources:
cur.execute(
"INSERT IGNORE INTO news_sources (name, code, description, is_active) VALUES (%s, %s, %s, 1)",
(name, code, desc),
)
print(f" [source] {code}: {name} — 已注册")
# 2. 创建 per-source 表
tables = {
"news_10jqka": """
CREATE TABLE IF NOT EXISTS news_10jqka (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
source_news_id VARCHAR(128) NOT NULL,
title VARCHAR(500) NOT NULL,
content TEXT,
url VARCHAR(500),
published_at BIGINT,
fetched_at DATETIME DEFAULT CURRENT_TIMESTAMP,
importance INT DEFAULT 0,
is_dup TINYINT DEFAULT 0,
summary TEXT,
tags JSON,
category VARCHAR(50) DEFAULT 'general',
UNIQUE KEY uq_sid (source_news_id),
INDEX idx_pub (published_at),
INDEX idx_imp (importance)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
""",
"news_xueqiu": """
CREATE TABLE IF NOT EXISTS news_xueqiu (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
source_news_id VARCHAR(128) NOT NULL,
title VARCHAR(500) NOT NULL,
content TEXT,
url VARCHAR(500),
published_at BIGINT,
fetched_at DATETIME DEFAULT CURRENT_TIMESTAMP,
importance INT DEFAULT 0,
is_dup TINYINT DEFAULT 0,
summary TEXT,
tags JSON,
category VARCHAR(50) DEFAULT 'general',
UNIQUE KEY uq_sid (source_news_id),
INDEX idx_pub (published_at),
INDEX idx_imp (importance)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
""",
}
for table_name, ddl in tables.items():
cur.execute(ddl)
print(f" [table] {table_name} — 已创建/确认")
conn.commit()
cur.close()
conn.close()
print("\n初始化完成!RSS 数据源已就绪。")
if __name__ == "__main__":
init()