Repository: github/issue-metrics
Pull request #519 (2025-05-08 22:13:54)

fix: remove mentor count from stats if mentors are disabled
# Pull Request

<!--
PR title needs to be prefixed with a conventional commit type
(build,chore,ci,docs,feat,fix,perf,refactor,revert,style,test)

It should also be brief and descriptive for a good changelog entry

examples: "feat: add new logger" or "fix: remove unused imports"
-->

## Proposed Changes

This pull request introduces a new feature to enable tracking and reporting of mentor activity metrics in the issue metrics system. The changes primarily involve adding a new `enable_mentor_count` parameter across various functions and updating the logic to conditionally display mentor-related data in the output.

## Readiness Checklist

### Author/Contributor

- [x] If documentation is needed for this change, has that been included in this pull request
- [x] run `make lint` and fix any issues that you have introduced
- [x] run `make test` and ensure you have test coverage for the lines you are introducing
- [x] If publishing new data to the public (scorecards, security scan results, code quality results, live dashboards, etc.), please request review from `@jeffrey-luszcz`

### Reviewer

- [x] Label as either `fix`, `documentation`, `enhancement`, `infrastructure`, `maintenance`, or `breaking`



Patch:
diff --git a/issue_metrics.py b/issue_metrics.py
index a1b3f11..ab9cb91 100644
--- a/issue_metrics.py
+++ b/issue_metrics.py
@@ -281,6 +281,7 @@ def main():  # pragma: no cover
                 search_query=search_query,
                 hide_label_metrics=False,
                 hide_items_closed_count=False,
+                enable_mentor_count=enable_mentor_count,
                 non_mentioning_links=False,
                 report_title=report_title,
                 output_file=output_file,
@@ -307,6 +308,7 @@ def main():  # pragma: no cover
                 search_query=search_query,
                 hide_label_metrics=False,
                 hide_items_closed_count=False,
+                enable_mentor_count=enable_mentor_count,
                 non_mentioning_links=False,
                 report_title=report_title,
                 output_file=output_file,
@@ -370,6 +372,7 @@ def main():  # pragma: no cover
         search_query=search_query,
         hide_label_metrics=hide_label_metrics,
         hide_items_closed_count=hide_items_closed_count,
+        enable_mentor_count=enable_mentor_count,
         non_mentioning_links=non_mentioning_links,
         report_title=report_title,
         output_file=output_file,
diff --git a/markdown_writer.py b/markdown_writer.py
index e506a4f..ed0d05d 100644
--- a/markdown_writer.py
+++ b/markdown_writer.py
@@ -100,6 +100,7 @@ def write_to_markdown(
     search_query=None,
     hide_label_metrics=False,
     hide_items_closed_count=False,
+    enable_mentor_count=False,
     non_mentioning_links=False,
     report_title="",
     output_file="",
@@ -168,6 +169,7 @@ def write_to_markdown(
             file,
             hide_label_metrics,
             hide_items_closed_count,
+            enable_mentor_count,
         )
 
         # Write second table with individual issue/pr/discussion metrics
@@ -243,6 +245,7 @@ def write_overall_metrics_tables(
     file,
     hide_label_metrics,
     hide_items_closed_count=False,
+    enable_mentor_count=False,
 ):
     """Write the overall metrics tables to the markdown file."""
     if any(
@@ -316,5 +319,6 @@ def write_overall_metrics_tables(
     file.write(f"| Number of items that remain open | {num_issues_opened} |\n")
     if not hide_items_closed_count:
         file.write(f"| Number of items closed | {num_issues_closed} |\n")
-    file.write(f"| Number of most active mentors | {num_mentor_count} |\n")
+    if enable_mentor_count:
+        file.write(f"| Number of most active mentors | {num_mentor_count} |\n")
     file.write(f"| Total number of items created | {len(issues_with_metrics)} |\n\n")


Test patch:
diff --git a/test_markdown_writer.py b/test_markdown_writer.py
index 3927106..e8f5b08 100644
--- a/test_markdown_writer.py
+++ b/test_markdown_writer.py
@@ -129,7 +129,6 @@ class TestWriteToMarkdown(unittest.TestCase):
             "| --- | ---: |\n"
             "| Number of items that remain open | 2 |\n"
             "| Number of items closed | 1 |\n"
-            "| Number of most active mentors | 5 |\n"
             "| Total number of items created | 2 |\n\n"
             "| Title | URL | Author | Time to first response | Time to close |"
             " Time to answer | Time in draft | Time spent in bug | Created At |\n"
@@ -240,7 +239,6 @@ class TestWriteToMarkdown(unittest.TestCase):
             "| --- | ---: |\n"
             "| Number of items that remain open | 2 |\n"
             "| Number of items closed | 1 |\n"
-            "| Number of most active mentors | 5 |\n"
             "| Total number of items created | 2 |\n\n"
             "| Title | URL | Author | Time to first response | Time to close |"
             " Time to answer | Time in draft | Time spent in bug | Created At |\n"
@@ -369,6 +367,7 @@ class TestWriteToMarkdownWithEnv(unittest.TestCase):
             search_query="repo:user/repo is:issue",
             hide_label_metrics=True,
             hide_items_closed_count=True,
+            enable_mentor_count=True,
             non_mentioning_links=True,
             report_title="Issue Metrics",
             output_file="issue_metrics.md",