correction du modules bug_report

This commit is contained in:
Mathis 2026-07-11 23:50:19 +02:00
parent f31a5d42fb
commit a87178b36d

View file

@ -16,6 +16,45 @@ TRACKING_FILE = os.path.join(BASE_DIR, "commandes", "gitlab_issues.json")
LEGACY_REPORTS_FILE = os.path.join(BASE_DIR, "data", "gitlab_reports.json")
def classify_webhook_event(payload: Dict[str, Any]) -> Optional[str]:
"""Détermine si un webhook correspond à une issue ou à un commentaire."""
object_kind = payload.get("object_kind")
if object_kind in {"issue", "note"}:
return object_kind
action = str(payload.get("action", "")).lower()
if action in {"comment_created", "comment_updated", "commented"} or "comment" in payload:
return "note"
if payload.get("issue") or payload.get("object_attributes") or action in {"open", "reopen", "close", "closed", "updated"}:
return "issue"
return None
def extract_issue_iid(payload: Dict[str, Any]) -> Optional[str]:
"""Extrait lidentifiant dissue depuis plusieurs formats Forgejo/GitLab."""
for container in (payload.get("object_attributes", {}), payload.get("issue", {}), payload.get("comment", {})):
if not isinstance(container, dict):
continue
for key in ("iid", "number", "id"):
value = container.get(key)
if value not in (None, ""):
return str(value)
return None
def extract_issue_identifier(issue_payload: Optional[Dict[str, Any]]) -> Optional[str]:
"""Récupère un identifiant stable à stocker dans le tracking."""
if not isinstance(issue_payload, dict):
return None
for key in ("iid", "number", "id"):
value = issue_payload.get(key)
if value not in (None, ""):
return str(value)
return None
def load_tracking():
"""Charge le tracking depuis gitlab_issues.json (avec migration automatique)"""
tracking = {}