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

feat: additional metrics for days since last release and PR #158

Merged
merged 1 commit into from
Jun 10, 2024

Conversation

zkoppert
Copy link
Member

@zkoppert zkoppert commented Jun 8, 2024

Pull Request

fixes #20

Proposed Changes

This pull request introduces a new feature that allows it to report additional metrics about repositories, such as the number of days since the last release or the last pull request. The changes also include updates to the .env-example and README.md files to reflect the new feature, and modifications to the stale_repos.py and test_stale_repos.py files to implement and test the new functionality.

One major technical change internally is that the inactive repos list is now structured as a list of dictionaries, with each dictionary containing the repository name, the number of days since the last release, and the number of days since the last pull request. This change was necessary to accommodate the new metrics each individually being optional.

I've ensured that the tests passed and also ran this locally against the github org with the expected results.

Readiness Checklist

Author/Contributor

  • If documentation is needed for this change, has that been included in this pull request
  • run make lint and fix any issues that you have introduced
  • run make test and ensure you have test coverage for the lines you are introducing
  • If publishing new data to the public (scorecards, security scan results, code quality results, live dashboards, etc.), please request review from @jeffrey-luszcz

Reviewer

  • Label as either fix, documentation, enhancement, infrastructure, maintenance or breaking

@zkoppert zkoppert marked this pull request as ready for review June 8, 2024 05:09
Comment on lines +157 to +186
def get_days_since_last_release(repo):
"""Get the number of days since the last release of the repository.

Args:
repo: A Github repository object.

Returns:
The number of days since the last release.
"""
try:
last_release = next(repo.releases())
return (datetime.now(timezone.utc) - last_release.created_at).days
except StopIteration:
return None


def get_days_since_last_pr(repo):
"""Get the number of days since the last pull request was made in the repository.

Args:
repo: A Github repository object.

Returns:
The number of days since the last pull request was made.
"""
try:
last_pr = next(repo.pull_requests(state="all"))
return (datetime.now(timezone.utc) - last_pr.created_at).days
except StopIteration:
return None
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Core functionality change

Copy link
Member

@jmeridth jmeridth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

.env-example Show resolved Hide resolved
README.md Show resolved Hide resolved
@zkoppert zkoppert merged commit a122c9f into main Jun 10, 2024
26 checks passed
@zkoppert zkoppert deleted the additional-metrics branch June 10, 2024 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add additional information to created issue
2 participants