Skip to content
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

fix: Fix headers in markdown to reflect when its limited to date range #165

Merged
merged 2 commits into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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