Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 94d1fa0
Author: Harrison <harrison.cook@ecmwf.int>
Date:   Thu Oct 17 11:12:33 2024 +0100

    Fix tests

commit 121ae4d
Author: Harrison <harrison.cook@ecmwf.int>
Date:   Thu Oct 17 11:09:46 2024 +0100

    Check order

commit 9e1a618
Author: Harrison <harrison.cook@ecmwf.int>
Date:   Thu Oct 17 11:08:36 2024 +0100

    Ordering of organisations

commit 7a8d07c
Merge: cf30c66 56c4ab4
Author: Harrison <harrison.cook@ecmwf.int>
Date:   Thu Oct 17 11:03:45 2024 +0100

    Merge branch 'initial-release' into testing

commit cf30c66
Author: Harrison <harrison.cook@ecmwf.int>
Date:   Thu Oct 17 10:56:02 2024 +0100

    Remove prints

commit 9382fe4
Author: Harrison <harrison.cook@ecmwf.int>
Date:   Thu Oct 17 09:29:35 2024 +0100

    Test multi repos

commit 3073b0c
Author: Harrison Cook <harrison@eldrest.com>
Date:   Wed Oct 16 22:50:07 2024 +0100

    Repistory is list

commit b17bda7
Author: Harrison Cook <harrison@eldrest.com>
Date:   Wed Oct 16 22:48:45 2024 +0100

    Fix repository split

commit c32c038
Author: Harrison Cook <harrison@eldrest.com>
Date:   Wed Oct 16 22:46:18 2024 +0100

    FIx main

commit 25b3c6d
Author: Harrison Cook <harrison@eldrest.com>
Date:   Wed Oct 16 22:40:53 2024 +0100

    Check if multi repos are being used

commit 52a46e2
Author: Harrison Cook <harrison@eldrest.com>
Date:   Wed Oct 16 22:34:09 2024 +0100

    Update action.yml

commit 2852ef8
Author: Harrison Cook <harrison@eldrest.com>
Date:   Wed Oct 16 22:27:22 2024 +0100

    Fix issue in README

commit cd1fec1
Author: Harrison Cook <harrison@eldrest.com>
Date:   Wed Oct 16 22:19:13 2024 +0100

    Restore pr-title

commit 310113c
Author: Harrison Cook <harrison@eldrest.com>
Date:   Wed Oct 16 22:16:16 2024 +0100

    Match upstream naming of organisation (organization)

commit b81302c
Author: Harrison Cook <harrison@eldrest.com>
Date:   Wed Oct 16 22:15:25 2024 +0100

    Update README
  • Loading branch information
HCookie committed Oct 17, 2024
1 parent 56c4ab4 commit 89fedd9
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/contributors_report_testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
# START_DATE: ${{ env.START_DATE }}
# END_DATE: ${{ env.END_DATE }}
REPOSITORY: hcookie/organizational_contributors,ecmwf/anemoi-training
SHOW_ORGANIZATIONS: ecmwf
SHOW_ORGANIZATIONS: ecmwf, ecmwf-lab
# SPONSOR_INFO: "true"

- name: Show Contributor
Expand Down
2 changes: 1 addition & 1 deletion contributors/json_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def write_to_json(
repository_list,
sponsor_info,
link_to_profile,
show_organizations_list
show_organizations_list,
):
"""Write data to a JSON file.
Expand Down
22 changes: 12 additions & 10 deletions contributors/markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""This module contains the functions needed to write the output to markdown files."""


from collections import defaultdict
from collections import defaultdict, OrderedDict

from .contributor_stats import ContributorStats

Expand Down Expand Up @@ -87,12 +87,8 @@ def write_markdown_file(filename, start_date, end_date, organization, repository
if len(table) == 1 and "Independent" in table:
markdown_file.write(table["Independent"])
else:
# Put independent last
orgs = list(table.keys())
if 'Independent' in orgs:
orgs.remove('Independent')
orgs.append('Independent')
for org in orgs:
# Put independent last
for org in list(table.keys()):
org_title = f"## [{org}](https://github.com/{org})\n" if not org == "Independent" else f"## {org} \n"
markdown_file.write(org_title)
markdown_file.write(table[org])
Expand Down Expand Up @@ -140,6 +136,7 @@ def get_summary_table(collaborators, start_date, end_date, total_contributions):

return summary_table


def get_contributor_table(
collaborators: list[ContributorStats],
start_date,
Expand Down Expand Up @@ -194,7 +191,6 @@ def get_contributor_table(

if not isinstance(repository, list):
repository = [repository]

if organization or len(repository) > 1:
# split the urls from the comma separated list and make them into markdown links
commit_url_list = collaborator.commit_url.split(",")
Expand Down Expand Up @@ -227,8 +223,14 @@ def get_contributor_table(

if not added_to_org:
organization_contributors["Independent"].append(row)

tables = {org: headers + "".join(rows) for org, rows in organization_contributors.items()}

ordered_orgs = [org for org in (*show_organizations_list, "Independent") if org in organization_contributors]
tables = OrderedDict(
[
(org, headers + "".join(organization_contributors[org]))
for org in ordered_orgs
]
)

# table += row
return tables, total_contributions
30 changes: 15 additions & 15 deletions tests/test_contributors.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ def test_get_contributors(self, mock_contributor_stats):
get_contributors(mock_repo, "2022-01-01", "2022-12-31")

mock_contributor_stats.assert_called_once_with(
username='user',
new_contributor=False,
avatar_url='https://github.com/avatars/u/12345678?v=4',
contribution_count = 100,
commit_url ='https://github.com/owner/repo/commits?author=user&since=2022-01-01&until=2022-12-31',
sponsor_info='',
organizations=[]
username="user",
new_contributor=False,
avatar_url="https://github.com/avatars/u/12345678?v=4",
contribution_count=100,
commit_url="https://github.com/owner/repo/commits?author=user&since=2022-01-01&until=2022-12-31",
sponsor_info="",
organizations=[],
)

@patch("contributors.get_contributors")
Expand All @@ -55,7 +55,7 @@ def test_get_all_contributors_with_organization(self, mock_get_contributors):
100,
"commit_url",
"sponsor_url_1",
[]
[],
),
]

Expand All @@ -65,13 +65,13 @@ def test_get_all_contributors_with_organization(self, mock_get_contributors):
result,
[
ContributorStats(
username = "user",
username="user",
new_contributor=False,
avatar_url = "https://github.com/avatars/u/29484535?v=4",
avatar_url="https://github.com/avatars/u/29484535?v=4",
contribution_count=200,
commit_url = "commit_url, commit_url",
sponsor_info = "sponsor_url_1",
organizations= [],
commit_url="commit_url, commit_url",
sponsor_info="sponsor_url_1",
organizations=[],
),
],
)
Expand Down Expand Up @@ -136,12 +136,12 @@ def test_get_contributors_skip_users_with_no_commits(self, mock_contributor_stat

# Note that only user is returned and user2 is not returned here because there were no commits in the date range
mock_contributor_stats.assert_called_once_with(
username = "user",
username="user",
new_contributor=False,
avatar_url="https://github.com/avatars/u/12345678?v=4",
contribution_count=100,
commit_url="https://github.com/owner/repo/commits?author=user&since=2022-01-01&until=2022-12-31",
sponsor_info='',
sponsor_info="",
organizations=[],
)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_json_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def setUp(self):
"new_contributor": False,
"avatar_url": "https://test_url.com",
"contribution_count": 10,
'organizations': [],
"organizations": [],
"commit_url": "https://test_commit_url.com",
"sponsor_info": "",
}
Expand Down

0 comments on commit 89fedd9

Please sign in to comment.