Skip to content

Commit b2d6716

Browse files
committed
applied reviewer suggestions, dir changes
1 parent e9bf055 commit b2d6716

1 file changed

Lines changed: 19 additions & 11 deletions

File tree

triage/bug_triage.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
"""
66

77
import glob
8+
import logging
89
import os
10+
from collections import defaultdict
911
from datetime import UTC, datetime
1012
from pathlib import Path
1113

@@ -14,6 +16,14 @@
1416
BUG_PATH = str(BASE_DIR / "production" / "qa" / "bugs" / "*.md")
1517
OUTPUT_PATH = str(BASE_DIR / "production" / "qa")
1618

19+
SEVERITY_KEYWORDS: dict[str, list[str]] = {
20+
"S1": ["crash", "data loss", "cannot start", "fatal"],
21+
"S2": ["broken", "not working", "fail"],
22+
"S3": ["slow", "incorrect", "glitch"],
23+
}
24+
25+
logger = logging.getLogger(__name__)
26+
1727

1828
def classify_severity(content: str) -> str:
1929
"""
@@ -25,12 +35,9 @@ def classify_severity(content: str) -> str:
2535
'S3'
2636
"""
2737
content = content.lower()
28-
if any(k in content for k in ["crash", "data loss", "cannot start", "fatal"]):
29-
return "S1"
30-
if any(k in content for k in ["broken", "not working", "fail"]):
31-
return "S2"
32-
if any(k in content for k in ["slow", "incorrect", "glitch"]):
33-
return "S3"
38+
for severity, keywords in SEVERITY_KEYWORDS.items():
39+
if any(k in content for k in keywords):
40+
return severity
3441
return "S4"
3542

3643

@@ -71,7 +78,7 @@ def read_bugs() -> list[dict]:
7178
"summary": content.strip().split("\n")[0][:80]
7279
})
7380
except OSError as e:
74-
print(f"⚠️ Could not read file {file_path}: {e}")
81+
logger.warning("Could not read file %s: %s", file_path, e)
7582

7683
return bugs
7784

@@ -93,10 +100,11 @@ def generate_report(bugs: list[dict]) -> None:
93100

94101
output_file = os.path.join(OUTPUT_PATH, f"bug-triage-{date}.md")
95102

96-
p1 = [b for b in bugs if b["priority"] == "P1"]
97-
p2 = [b for b in bugs if b["priority"] == "P2"]
98-
p3 = [b for b in bugs if b["priority"] == "P3"]
99-
p4 = [b for b in bugs if b["priority"] == "P4"]
103+
grouped: defaultdict[str, list[dict]] = defaultdict(list)
104+
for b in bugs:
105+
grouped[b["priority"]].append(b)
106+
107+
p1, p2, p3, p4 = grouped["P1"], grouped["P2"], grouped["P3"], grouped["P4"]
100108

101109
report_content = [
102110
"# Bug Triage Report",

0 commit comments

Comments
 (0)