32 lines
1.4 KiB
Python
32 lines
1.4 KiB
Python
# -*- 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()
|
|
|
|
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 '%孙颖%')""")
|
|
print("5月测试需求:", len(rows), "个")
|
|
ids = ','.join(str(r[0]) for r in rows) or '0'
|
|
|
|
bugs = q(f"""SELECT id, tostory, severity, status FROM zt_bug
|
|
WHERE openedby='sunying' AND deleted='0' AND tostory IN ({ids})
|
|
AND openeddate>='2026-05-01' AND openeddate<'2026-06-01'""")
|
|
print("她5月提的、tostory在范围内的Bug:", len(bugs), "个")
|
|
for r in bugs: print(r)
|
|
|
|
dev = q(f"""SELECT SUM(t.estimate) FROM zt_task t
|
|
WHERE t.story IN ({ids}) AND t.type='devel' AND t.status NOT IN ('cancel','closed') AND t.deleted='0'""")[0][0]
|
|
serious = sum(1 for r in bugs if r[2]==1)
|
|
slight = sum(1 for r in bugs if r[2] in (2,3,4))
|
|
w = serious*5 + slight
|
|
print(f"严重={serious} 轻微={slight} 加权={w} 分母devel工时={dev}")
|
|
if dev:
|
|
rate = w/float(dev)*100
|
|
print(f"检出率×100 = {rate:.1f} → 得分: {'30满分' if rate>20 else max(0,30-(20-int(rate))*2)}")
|