-
Notifications
You must be signed in to change notification settings - Fork 23
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, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.