Updata2
This commit is contained in:
57
etl_billiards/scripts/check_intimacy_stats.py
Normal file
57
etl_billiards/scripts/check_intimacy_stats.py
Normal file
@@ -0,0 +1,57 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import sys
|
||||
sys.path.insert(0, '.')
|
||||
from config.settings import AppConfig
|
||||
from database.connection import DatabaseConnection
|
||||
from database.operations import DatabaseOperations
|
||||
|
||||
config = AppConfig.load()
|
||||
db_conn = DatabaseConnection(config.config['db']['dsn'])
|
||||
db = DatabaseOperations(db_conn)
|
||||
|
||||
# 检查实际统计
|
||||
sql = """
|
||||
SELECT
|
||||
COUNT(*) as total_pairs,
|
||||
COUNT(DISTINCT member_id) as unique_members,
|
||||
COUNT(DISTINCT assistant_id) as unique_assistants
|
||||
FROM billiards_dws.dws_member_assistant_intimacy
|
||||
"""
|
||||
rows = db.query(sql)
|
||||
r = dict(rows[0])
|
||||
print("DWS亲密指数统计:")
|
||||
print(f" 总记录数(对): {r['total_pairs']}")
|
||||
print(f" 唯一会员数: {r['unique_members']}")
|
||||
print(f" 唯一助教数: {r['unique_assistants']}")
|
||||
|
||||
# 查看助教分布
|
||||
sql2 = """
|
||||
SELECT assistant_id, COUNT(*) as member_count
|
||||
FROM billiards_dws.dws_member_assistant_intimacy
|
||||
GROUP BY assistant_id
|
||||
ORDER BY member_count DESC
|
||||
LIMIT 10
|
||||
"""
|
||||
rows2 = db.query(sql2)
|
||||
print()
|
||||
print("Top 10 助教 (按服务会员数):")
|
||||
for row in rows2:
|
||||
r = dict(row)
|
||||
print(f" 助教 {r['assistant_id']}: 服务 {r['member_count']} 个会员")
|
||||
|
||||
# 检查DWD层原始数据
|
||||
sql3 = """
|
||||
SELECT
|
||||
COUNT(DISTINCT site_assistant_id) as unique_assistants,
|
||||
COUNT(DISTINCT tenant_member_id) as unique_members
|
||||
FROM billiards_dwd.dwd_assistant_service_log
|
||||
WHERE tenant_member_id > 0 AND is_delete = 0
|
||||
"""
|
||||
rows3 = db.query(sql3)
|
||||
r3 = dict(rows3[0])
|
||||
print()
|
||||
print("DWD层原始数据:")
|
||||
print(f" 唯一助教数: {r3['unique_assistants']}")
|
||||
print(f" 唯一会员数: {r3['unique_members']}")
|
||||
|
||||
db_conn.close()
|
||||
Reference in New Issue
Block a user