Generate a detailed statistics report
(self, statistics_data: List[Dict[str, Any]])
| 1320 | } |
| 1321 | |
| 1322 | def generate_statistics_report(self, statistics_data: List[Dict[str, Any]]) -> str: |
| 1323 | """Generate a detailed statistics report""" |
| 1324 | stats_path = self.output_dir / self.stats_filename |
| 1325 | |
| 1326 | # Calculate aggregate statistics |
| 1327 | total_repos = len(statistics_data) |
| 1328 | total_files_analyzed = sum(stat["analyzed_files"] for stat in statistics_data) |
| 1329 | total_relationships = sum( |
| 1330 | stat["total_relationships"] for stat in statistics_data |
| 1331 | ) |
| 1332 | total_lines = sum(stat["total_lines_of_code"] for stat in statistics_data) |
| 1333 | |
| 1334 | # Aggregate relationship types |
| 1335 | aggregated_rel_types = {} |
| 1336 | for stat in statistics_data: |
| 1337 | for rel_type, count in stat["relationship_type_counts"].items(): |
| 1338 | aggregated_rel_types[rel_type] = ( |
| 1339 | aggregated_rel_types.get(rel_type, 0) + count |
| 1340 | ) |
| 1341 | |
| 1342 | # Aggregate file types |
| 1343 | aggregated_file_types = {} |
| 1344 | for stat in statistics_data: |
| 1345 | for file_type, count in stat["file_type_counts"].items(): |
| 1346 | aggregated_file_types[file_type] = ( |
| 1347 | aggregated_file_types.get(file_type, 0) + count |
| 1348 | ) |
| 1349 | |
| 1350 | # Calculate averages |
| 1351 | avg_files_per_repo = total_files_analyzed / total_repos if total_repos else 0 |
| 1352 | avg_relationships_per_repo = ( |
| 1353 | total_relationships / total_repos if total_repos else 0 |
| 1354 | ) |
| 1355 | avg_lines_per_repo = total_lines / total_repos if total_repos else 0 |
| 1356 | |
| 1357 | # Build statistics report |
| 1358 | statistics_report = { |
| 1359 | "report_generation_time": datetime.now().isoformat(), |
| 1360 | "analyzer_version": "1.4.0", |
| 1361 | "configuration_used": { |
| 1362 | "config_file": self.indexer_config_path, |
| 1363 | "concurrent_analysis_enabled": self.enable_concurrent_analysis, |
| 1364 | "content_caching_enabled": self.enable_content_caching, |
| 1365 | "pre_filtering_enabled": self.enable_pre_filtering, |
| 1366 | "min_confidence_score": self.min_confidence_score, |
| 1367 | "high_confidence_threshold": self.high_confidence_threshold, |
| 1368 | }, |
| 1369 | "aggregate_statistics": { |
| 1370 | "total_repositories_processed": total_repos, |
| 1371 | "total_files_analyzed": total_files_analyzed, |
| 1372 | "total_relationships_found": total_relationships, |
| 1373 | "total_lines_of_code": total_lines, |
| 1374 | "average_files_per_repository": round(avg_files_per_repo, 2), |
| 1375 | "average_relationships_per_repository": round( |
| 1376 | avg_relationships_per_repo, 2 |
| 1377 | ), |
| 1378 | "average_lines_per_repository": round(avg_lines_per_repo, 2), |
| 1379 | }, |