-
Notifications
You must be signed in to change notification settings - Fork 25
feat: add company column to contributor output #394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
411cfca
c70e4ac
501d048
440e06e
21971a6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
| # [ | ||
| # { | ||
| # "username" : "zkoppert", | ||
| # "company" : "@github", | ||
| # "new_contributor" : "False", | ||
| # "avatar_url" : "https://avatars.githubusercontent.com/u/29484535?v=4", | ||
| # "contribution_count" : 1261, | ||
|
|
@@ -23,6 +24,7 @@ class ContributorStats: | |
|
|
||
| Attributes: | ||
| username (str): The username of the contributor | ||
| company (str): The company listed on the contributor's GitHub profile | ||
| new_contributor (bool): Whether the contributor is new or returning | ||
| avatar_url (str): The url of the contributor's avatar | ||
| contribution_count (int): The number of contributions the contributor has made | ||
|
|
@@ -38,6 +40,7 @@ def __new__(cls, *args, **kwargs): # pylint: disable=unused-argument | |
| def __init__( | ||
| self, | ||
| username: str, | ||
| company: str, | ||
| new_contributor: bool, | ||
| avatar_url: str, | ||
| contribution_count: int, | ||
|
|
@@ -47,6 +50,7 @@ def __init__( | |
| """Initialize the contributor_stats object""" | ||
| new_contributor = False | ||
| self.username = username | ||
| self.company = company | ||
| self.new_contributor = new_contributor | ||
| self.avatar_url = avatar_url | ||
|
Comment on lines
50
to
55
|
||
| self.contribution_count = contribution_count | ||
|
|
@@ -57,6 +61,7 @@ def __repr__(self) -> str: | |
| """Return the representation of the contributor_stats object""" | ||
| return ( | ||
| f"contributor_stats(username={self.username}, " | ||
| f"company={self.company}, " | ||
| f"new_contributor={self.new_contributor}, " | ||
| f"avatar_url={self.avatar_url}, " | ||
| f"contribution_count={self.contribution_count}, " | ||
|
|
@@ -68,6 +73,7 @@ def __eq__(self, other) -> bool: | |
| """Check if two contributor_stats objects are equal""" | ||
| return ( | ||
| self.username == other.username | ||
| and self.company == other.company | ||
| and self.new_contributor == other.new_contributor | ||
| and self.avatar_url == other.avatar_url | ||
| and self.contribution_count == other.contribution_count | ||
|
|
@@ -122,6 +128,8 @@ def merge_contributors(contributors: list) -> list: | |
| merged_contributor.new_contributor | ||
| or contributor.new_contributor | ||
| ) | ||
| if not merged_contributor.company and contributor.company: | ||
| merged_contributor.company = contributor.company | ||
|
|
||
| else: | ||
| merged_contributors.append(contributor) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -181,8 +181,10 @@ def get_contributors(repo: object, start_date: str, end_date: str, ghe: str): | |
| commit_url = f"{endpoint}/{repo.full_name}/commits?author={user.login}&since={start_date}&until={end_date}" | ||
| else: | ||
| commit_url = f"{endpoint}/{repo.full_name}/commits?author={user.login}" | ||
| company = getattr(user, "company", "") or "" | ||
| contributor = contributor_stats.ContributorStats( | ||
| user.login, | ||
| company, | ||
| False, | ||
|
Comment on lines
181
to
188
|
||
| user.avatar_url, | ||
| user.contributions_count, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,14 +25,13 @@ def write_to_markdown( | |
| """ | ||
| This function writes a list of collaborators to a markdown file in table format | ||
| and optionally to GitHub Actions Job Summary if running in a GitHub Actions environment. | ||
| Each collaborator is represented as a dictionary with keys 'username', | ||
| 'contribution_count', 'new_contributor', and 'commits'. | ||
| Each collaborator is represented as a ContributorStats object with fields | ||
| 'username', 'company', 'contribution_count', 'new_contributor', and 'commit_url'. | ||
|
|
||
| Args: | ||
| collaborators (list): A list of dictionaries, where each dictionary | ||
| represents a collaborator. Each dictionary should | ||
| have the keys 'username', 'contribution_count', | ||
| and 'commits'. | ||
| collaborators (list): A list of ContributorStats objects. Each object should | ||
| have the fields 'username', 'company', 'contribution_count', | ||
| 'new_contributor', and 'commit_url'. | ||
| filename (str): The path of the markdown file to which the table will | ||
| be written. | ||
| start_date (str): The start date of the date range for the contributor | ||
|
|
@@ -166,8 +165,9 @@ def get_summary_table(collaborators, start_date, end_date, total_contributions): | |
| This function returns a string containing a markdown table of the summary statistics. | ||
|
|
||
| Args: | ||
| collaborators (list): A list of dictionaries, where each dictionary represents a collaborator. | ||
| Each dictionary should have the keys 'username', 'contribution_count', and 'commits'. | ||
| collaborators (list): A list of ContributorStats objects. | ||
| Each object should have the fields 'username', 'company', | ||
| 'contribution_count', and 'new_contributor'. | ||
| start_date (str): The start date of the date range for the contributor list. | ||
| end_date (str): The end date of the date range for the contributor list. | ||
| total_contributions (int): The total number of contributions made by all of the contributors. | ||
|
|
@@ -212,8 +212,9 @@ def get_contributor_table( | |
| This function returns a string containing a markdown table of the contributors and the total contribution count. | ||
|
|
||
| Args: | ||
| collaborators (list): A list of dictionaries, where each dictionary represents a collaborator. | ||
| Each dictionary should have the keys 'username', 'contribution_count', and 'commits'. | ||
| collaborators (list): A list of ContributorStats objects. | ||
| Each object should have the fields 'username', 'company', | ||
| 'contribution_count', 'commit_url', and 'new_contributor'. | ||
| start_date (str): The start date of the date range for the contributor list. | ||
| end_date (str): The end date of the date range for the contributor list. | ||
| organization (str): The organization for which the contributors are being listed. | ||
|
|
@@ -230,7 +231,7 @@ def get_contributor_table( | |
| sponsor_info = _is_truthy(sponsor_info) | ||
| show_avatar = _is_truthy(show_avatar) | ||
| link_to_profile = _is_truthy(link_to_profile) | ||
| columns = ["Username", "All Time Contribution Count"] | ||
| columns = ["Username", "Company", "All Time Contribution Count"] | ||
| if show_avatar: | ||
| columns.insert(0, "Avatar") | ||
| if start_date and end_date: | ||
|
|
@@ -252,6 +253,7 @@ def get_contributor_table( | |
| total_contributions += collaborator.contribution_count | ||
| username = collaborator.username | ||
| contribution_count = collaborator.contribution_count | ||
| company = collaborator.company or "-" | ||
| if repository: | ||
| commit_urls = collaborator.commit_url | ||
| if organization: | ||
|
|
@@ -275,9 +277,7 @@ def get_contributor_table( | |
| else "" | ||
| ) | ||
| row += f"{avatar_cell} | " | ||
| row += ( | ||
| f"{'' if not link_to_profile else '@'}{username} | {contribution_count} |" | ||
| ) | ||
| row += f"{'' if not link_to_profile else '@'}{username} | {company} | {contribution_count} |" | ||
| if "New Contributor" in columns: | ||
|
Comment on lines
256
to
281
|
||
| row += f" {new_contributor} |" | ||
| if "Sponsor URL" in columns: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.