Get error database statistics.
(self)
| 325 | return match.group(1) if match else "N" |
| 326 | |
| 327 | def get_statistics(self) -> Dict[str, Any]: |
| 328 | """Get error database statistics.""" |
| 329 | total_errors = len(self._cache) |
| 330 | total_seen = sum(p.times_seen for p in self._cache.values()) |
| 331 | total_fixed = sum(p.times_fixed for p in self._cache.values()) |
| 332 | |
| 333 | # Group by error type |
| 334 | by_type = defaultdict(int) |
| 335 | for pattern in self._cache.values(): |
| 336 | by_type[pattern.error_type] += pattern.times_seen |
| 337 | |
| 338 | # Success rate |
| 339 | success_rate = (total_fixed / total_seen * 100) if total_seen > 0 else 0 |
| 340 | |
| 341 | return { |
| 342 | "total_patterns": total_errors, |
| 343 | "total_occurrences": total_seen, |
| 344 | "total_fixed": total_fixed, |
| 345 | "success_rate": f"{success_rate:.1f}%", |
| 346 | "by_type": dict(by_type), |
| 347 | "most_common": max(by_type.items(), key=lambda x: x[1])[0] if by_type else None, |
| 348 | } |
| 349 | |
| 350 | def clear(self): |
| 351 | """Clear error database.""" |
no outgoing calls