Files
group_xinghuo_jinrong/scripts/dev/inspect_seed.py
T

25 lines
1.4 KiB
Python
Raw Normal View History

"""查看种子数据关键事实(用于集成测试与演示)。"""
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
from app.service.analytics_repo import AnalyticsRepo
def main():
repo = AnalyticsRepo()
q = lambda sql: repo.execute_readonly(sql) # noqa: E731
print("advisor ids:", [r[0] for r in q("SELECT staff_id FROM core_staff WHERE staff_type='advisor' AND is_active=1 LIMIT 5")["rows"]])
print("risk_officer ids:", [r[0] for r in q("SELECT staff_id FROM core_staff WHERE staff_type='risk_officer' AND is_active=1 LIMIT 5")["rows"]])
print("ops ids:", [r[0] for r in q("SELECT staff_id FROM core_staff WHERE staff_type='ops' AND is_active=1 LIMIT 5")["rows"]])
print("analyst ids:", [r[0] for r in q("SELECT staff_id FROM core_staff WHERE staff_type='analyst' AND is_active=1 LIMIT 5")["rows"]])
print("risk codes:", q("SELECT risk_code, COUNT(*) c FROM core_customer_risk GROUP BY risk_code ORDER BY risk_code")["rows"])
print("product types:", q("SELECT product_type, COUNT(*) c FROM core_product GROUP BY product_type")["rows"])
print("alert status:", q("SELECT status, COUNT(*) c FROM jinrong_agent.risk_alert GROUP BY status")["rows"])
print("customers sample:", [r[0] for r in q("SELECT customer_id FROM core_customer LIMIT 8")["rows"]])
if __name__ == "__main__":
main()