Skip to content

Commit

Permalink
Merge pull request #165 from github/fix-contribution-count-headers
Browse files Browse the repository at this point in the history
fix: Fix headers in markdown to reflect when its limited to date range
  • Loading branch information
zkoppert committed Aug 24, 2024
2 parents 490a611 + 73e7b14 commit 1286dc8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ jobs:
| ------------------ | ------------------- | ------------------ |
| 1 | 143 | 0% |
| Username | Contribution Count | New Contributor | Commits |
| --------- | ------------------ | --------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| @zkoppert | 143 | False | [super-linter/super-linter](https://github.com/super-linter/super-linter/commits?author=zkoppert&since=2021-01-01&until=2023-10-10) |
| Username | All Time Contribution Count | New Contributor | Commits between 2021-01-01 and 2023-10-10 |
| --------- | --------------------------- | --------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| @zkoppert | 143 | False | [super-linter/super-linter](https://github.com/super-linter/super-linter/commits?author=zkoppert&since=2021-01-01&until=2023-10-10) |
```

## Example Markdown output with no dates supplied
Expand All @@ -171,9 +171,9 @@ jobs:
| ------------------ | ------------------- | ------------------ |
| 1 | 1913 | 0% |
| Username | Contribution Count | New Contributor | Sponsor URL | Commits |
| --------- | ------------------ | --------------- | ---------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| @zkoppert | 1913 | False | [Sponsor Link](https://github.com/sponsors/zkoppert) | [super-linter/super-linter](https://github.com/super-linter/super-linter/commits?author=zkoppert&since=2021-09-01&until=2023-09-30) |
| Username | All Time Contribution Count | New Contributor | Sponsor URL | Commits between 2021-09-01 and 2023-09-30 |
| --------- | --------------------------- | --------------- | ---------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| @zkoppert | 1913 | False | [Sponsor Link](https://github.com/sponsors/zkoppert) | [super-linter/super-linter](https://github.com/super-linter/super-linter/commits?author=zkoppert&since=2021-09-01&until=2023-09-30) |
```

## Local usage without Docker
Expand Down
7 changes: 5 additions & 2 deletions markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,15 @@ def get_contributor_table(
total_contributions (int): The total number of contributions made by all of the contributors.
"""
columns = ["Username", "Contribution Count"]
columns = ["Username", "All Time Contribution Count"]
if start_date and end_date:
columns += ["New Contributor"]
if sponsor_info == "true":
columns += ["Sponsor URL"]
columns += ["Commits"]
if start_date and end_date:
columns += [f"Commits between {start_date} and {end_date}"]
else:
columns += ["All Commits"]

headers = "| " + " | ".join(columns) + " |\n"
headers += "| " + " | ".join(["---"] * len(columns)) + " |\n"
Expand Down
6 changes: 3 additions & 3 deletions test_markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def test_write_to_markdown(self, mock_file):
"| Total Contributors | Total Contributions | % New Contributors |\n| --- | --- | --- |\n| 2 | 300 | 50.0% |\n\n"
)
mock_file().write.assert_any_call(
"| Username | Contribution Count | New Contributor | Commits |\n"
"| Username | All Time Contribution Count | New Contributor | Commits between 2023-01-01 and 2023-01-02 |\n"
"| --- | --- | --- | --- |\n"
"| @user1 | 100 | False | commit url |\n"
"| @user2 | 200 | True | commit url2 |\n"
Expand Down Expand Up @@ -114,7 +114,7 @@ def test_write_to_markdown_with_sponsors(self, mock_file):
"| Total Contributors | Total Contributions | % New Contributors |\n| --- | --- | --- |\n| 2 | 300 | 50.0% |\n\n"
)
mock_file().write.assert_any_call(
"| Username | Contribution Count | New Contributor | Sponsor URL | Commits |\n"
"| Username | All Time Contribution Count | New Contributor | Sponsor URL | Commits between 2023-01-01 and 2023-01-02 |\n"
"| --- | --- | --- | --- | --- |\n"
"| @user1 | 100 | False | [Sponsor Link](sponsor_url_1) | commit url |\n"
"| @user2 | 200 | True | not sponsorable | commit url2 |\n"
Expand Down Expand Up @@ -168,7 +168,7 @@ def test_write_to_markdown_without_link_to_profile(self, mock_file):
"| Total Contributors | Total Contributions | % New Contributors |\n| --- | --- | --- |\n| 2 | 300 | 50.0% |\n\n"
)
mock_file().write.assert_any_call(
"| Username | Contribution Count | New Contributor | Commits |\n"
"| Username | All Time Contribution Count | New Contributor | Commits between 2023-01-01 and 2023-01-02 |\n"
"| --- | --- | --- | --- |\n"
"| user1 | 100 | False | commit url |\n"
"| user2 | 200 | True | commit url2 |\n"
Expand Down

0 comments on commit 1286dc8

Please sign in to comment.