Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
chesha1 committed Jul 11, 2024
1 parent a30f565 commit 98b8d59
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ def calculate_contributions_by_company(repo: Repository, companies: List[str], n
company = contributor.company
if company is None:
continue
company = company.upper()
company = company.replace('@', '').strip()
company = company.upper().replace('@', '').strip()

count = False
for target_company in companies:
Expand Down Expand Up @@ -117,11 +116,8 @@ def calculate_single_company_contributions(repo: Repository, company: str, n: Op
if n is None or n > len(contributors):
n = len(contributors)
for contributor in tqdm(contributors[:n], desc='Fetching contributors'):
contributor_company = contributor.company
if contributor_company is None:
contributor_company = ''
contributor_company = contributor_company.upper()
contributor_company = contributor_company.replace('@', '').strip()
contributor_company = (
contributor.company or '').upper().replace('@', '').strip()

if contributor_company.find(company) != -1:
company_contributions += contributor.contributions
Expand All @@ -133,11 +129,12 @@ def calculate_single_company_contributions(repo: Repository, company: str, n: Op
if __name__ == "__main__":
token = 'ghp_example'
username = 'kubernetes'
companies = ['GOOGLE', 'MICROSOFT', 'INTEL']
companies = ['GOOGLE', 'MICROSOFT', 'INTEL',
'Red Hat', 'Databricks', 'Amazon Web Services', 'Goldman Sachs']

repos = get_top_starred_repos(username, 5, token)
repo = repos[0]
result1 = calculate_contributions_by_company(repo, companies, 10)
result1 = calculate_contributions_by_company(repo, companies, 100)
print(f'Contributions by company: {result1}')
result2 = calculate_single_company_contributions(repo, companies[0], 10)
result2 = calculate_single_company_contributions(repo, companies[0], 100)
print(f'Contributions by single company {companies[0]}: {result2}')

0 comments on commit 98b8d59

Please sign in to comment.