Skip to content

Commit

Permalink
Make mentor counting configurable.
Browse files Browse the repository at this point in the history
This adds two configuration options: One to enable mentor counting and one for
configuring how many comments a user needs to leave in discussions, PRs. and
issues to be counted as an active mentor.
  • Loading branch information
MaineC committed Mar 27, 2024
1 parent dcce0ab commit e5f7987
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ Below are the allowed configuration options:
| `HIDE_TIME_TO_ANSWER` | False | | If set to any value, the time to answer a discussion will not be displayed in the generated markdown file. |
| `HIDE_LABEL_METRICS` | False | | If set to any value, the time in label metrics will not be displayed in the generated markdown file. |
| `IGNORE_USERS` | False | | A comma separated list of users to ignore when calculating metrics. (ie. `IGNORE_USERS: 'user1,user2'`). To ignore bots, append `[bot]` to the user (ie. `IGNORE_USERS: 'github-actions[bot]'`) |

| `ENABLE_MENTOR_COUNT` | False | False | If set to 'TRUE' count number of comments users left on discussions, issues and PRs and display number of active mentors |
| `MIN_MENTOR_COMMENTS` | False | 10 | Minimum number of comments to count as a mentor |
## Further Documentation

- [Example workflows](./docs/example-workflows.md)
Expand Down
14 changes: 12 additions & 2 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@ class EnvVars:
hide_time_to_close (str): If set, the time to close metric is hidden in the output
hide_time_to_answer (str): If set, the time to answer discussions is hidden in the output
hide_label_metrics (str): If set, the label metrics are hidden in the output
enable_mentor_count (str): If set to TRUE, compute number of mentors
min_mentor_comments (str): If set, defines the minimum number of comments for mentors
"""
def __init__(self, search_query: str, gh_token: str, labels_to_measure: List[str], ignore_user: List[str],
github_server_url: str, hide_author: str, hide_time_to_first_response: str,
hide_time_to_close: str, hide_time_to_answer: str, hide_label_metrics: str):
hide_time_to_close: str, hide_time_to_answer: str,
hide_label_metrics: str, enable_mentor_count: str,
min_mentor_comments: str):
self.search_query = search_query
self.gh_token = gh_token
self.labels_to_measure = labels_to_measure
Expand All @@ -42,6 +46,8 @@ def __init__(self, search_query: str, gh_token: str, labels_to_measure: List[str
self.hide_time_to_close = hide_time_to_close
self.hide_time_to_answer = hide_time_to_answer
self.hide_label_metrics = hide_label_metrics
self.enable_mentor_count = enable_mentor_count
self.min_mentor_comments = min_mentor_comments


def get_env_vars() -> EnvVars:
Expand Down Expand Up @@ -78,6 +84,8 @@ def get_env_vars() -> EnvVars:
hide_time_to_close = os.getenv("HIDE_TIME_TO_CLOSE")
hide_time_to_answer = os.getenv("HIDE_TIME_TO_ANSWER")
hide_label_metrics = os.getenv("HIDE_LABEL_METRICS")
enable_mentor_count = os.getenv("ENABLE_MENTOR_COUNT", "FALSE")
min_mentor_comments = os.getenv("MIN_MENTOR_COMMENTS", "10")

return EnvVars(
search_query,
Expand All @@ -89,5 +97,7 @@ def get_env_vars() -> EnvVars:
hide_time_to_first_response,
hide_time_to_close,
hide_time_to_answer,
hide_label_metrics
hide_label_metrics,
enable_mentor_count,
min_mentor_comments
)
7 changes: 5 additions & 2 deletions issue_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,9 @@ def main():
search_query = env_vars.search_query
token = env_vars.gh_token
ignore_users = env_vars.ignore_users
enable_mentor_count = env_vars.enable_mentor_count

min_mentor_count = 10
min_mentor_count = int(env_vars.min_mentor_comments)

# Get the repository owner and name from the search query
owner = get_owner(search_query)
Expand Down Expand Up @@ -308,7 +309,9 @@ def main():

stats_time_to_answer = get_stats_time_to_answer(issues_with_metrics)

num_mentor_count = get_mentor_count(issues_with_metrics, min_mentor_comments)
num_mentor_count = 0
if enable_mentor_count == "TRUE":
num_mentor_count = get_mentor_count(issues_with_metrics, min_mentor_comments)

# Get stats describing the time in label for each label and store it in a dictionary
# where the key is the label and the value is the average time
Expand Down

0 comments on commit e5f7987

Please sign in to comment.