Files
zentao-flow/tmp/check_q1d.py
T

48 lines
2.7 KiB
Python
Raw 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.
# -*- coding: utf-8 -*-
import io, sys, pymysql
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
conn = pymysql.connect(host='192.168.1.161', user='devgps', password='dev@2021GPS',
database='zentao_dev_2026', charset='utf8mb4')
cur = conn.cursor()
def q(sql):
cur.execute(sql); return cur.fetchall()
# 产品组 → 测试人员映射(按 product_ids 授权)
print("-- 产品名称 --")
for r in q("SELECT id, name FROM zt_product WHERE id IN (119,139,145,147,150,161,189,215)"):
print(r)
print("\n### 按测试人员统计 6月检出率(CHG-054 口径:assignedTo ∪ test_person,当月上线)")
testers = {'sunying':'孙颖','zhangfubin':'张富斌','sunqingfang':'孙庆芳','luoyulu':'罗雨露','zhouxueli':'周雪丽'}
for acc, name in testers.items():
rows = q(f"""
SELECT DISTINCT s.id FROM zt_story s
LEFT JOIN zt_story_expand e ON e.story_id=s.id
WHERE s.releaseddate>='2026-06-01' AND s.releaseddate<'2026-07-01' AND s.deleted='0'
AND (s.assignedTo='{acc}' OR e.test_person LIKE '%{name}%')
""")
ids = [str(r[0]) for r in rows]
if not ids:
print(f"{name}: 无需求"); continue
idlist = ','.join(ids)
dev = q(f"SELECT SUM(t.estimate) FROM zt_task t WHERE t.story IN ({idlist}) AND t.type='devel' AND t.deleted='0'")[0][0]
nb = q(f"SELECT COUNT(*) FROM zt_bug WHERE story IN ({idlist}) AND deleted='0' AND severity IN (3,4)")[0][0]
mb = q(f"SELECT COUNT(*) FROM zt_bug WHERE story IN ({idlist}) AND deleted='0' AND severity IN (1,2)")[0][0]
w = nb*1 + mb*5
dev = float(dev or 0)
print(f"{name}({acc}): 需求{len(rows)}个 Σ开发工时={dev:.1f} 普通Bug={nb} 重大={mb} 加权={w} → ×100={'%.2f'%(w/dev*100) if dev else 'NA'}% ×1000={'%.1f'%(w/dev*1000) if dev else 'NA'}‰")
print("\n### 5月对照(孙颖曾 48% 满分)")
rows = q("""
SELECT DISTINCT s.id FROM zt_story s
LEFT JOIN zt_story_expand e ON e.story_id=s.id
WHERE s.releaseddate>='2026-05-01' AND s.releaseddate<'2026-06-01' AND s.deleted='0'
AND (s.assignedTo='sunying' OR e.test_person LIKE '%孙颖%')
""")
ids = ','.join(str(r[0]) for r in rows) or '0'
dev = q(f"SELECT SUM(t.estimate) FROM zt_task t WHERE t.story IN ({ids}) AND t.type='devel' AND t.deleted='0'")[0][0]
nb = q(f"SELECT COUNT(*) FROM zt_bug WHERE story IN ({ids}) AND deleted='0' AND severity IN (3,4)")[0][0]
mb = q(f"SELECT COUNT(*) FROM zt_bug WHERE story IN ({ids}) AND deleted='0' AND severity IN (1,2)")[0][0]
w = nb + mb*5; dev = float(dev or 0)
print(f"孙颖5月: 需求{len(rows)}个 Σ开发工时={dev:.1f} 普通={nb} 重大={mb} 加权={w} → ×100={'%.2f'%(w/dev*100) if dev else 'NA'}% ×1000={'%.1f'%(w/dev*1000) if dev else 'NA'}‰")