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 #21294 : Drop inactive contributors from issues that they aren't working on. #21377

Closed
wants to merge 7 commits into from
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
script updated => correct method imported
  • Loading branch information
Ashu463 committed Nov 23, 2024
commit a0118f7886799b891dbafbbb30290134840bb380
16 changes: 12 additions & 4 deletions scripts/inactive_issue_checker.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,36 @@
import os
import datetime
from github import Github

INACTIVE_DAYS = 7

def check_inactive_issues(github_token, repo_owner, repo_name):
"""
Check for inactive issues in the given repository and unassign them if necessary.
"""
g = Github(github_token)
repo = g.get_repo(f"{repo_owner}/{repo_name}")

for issue in repo.get_issues(state="open", assignee="*"):
if not issue.assignee:
continue

timeline = list(issue.get_events())

last_activity_date = max(event.created_at for event in timeline)

now = datetime.datetime.now(datetime.timezone.utc)
days_since_activity = (now - last_activity_date).total_seconds() / 86400
days_since_activity = (now - last_activity_date).total_seconds() / 86400

if days_since_activity > INACTIVE_DAYS:
issue.remove_assignees([issue.assignee])
# Fixed method name from remove_assignees to remove_from_assignees
issue.remove_from_assignees([issue.assignee])
issue.create_comment(
f"@{issue.assignee.login} has been unassigned from this issue due to inactivity for more than {INACTIVE_DAYS} days. If you'd like to continue working on this issue, please request to be reassigned."
f"@{issue.assignee.login} has been unassigned from this issue due to "
f"inactivity for more than {INACTIVE_DAYS} days. If you'd like to "
f"continue working on this issue, please request to be reassigned."
)
print(f"Unassigned issue #{issue.number} from {issue.assignee.login} due to inactivity")

if __name__ == "__main__":
github_token = os.environ["GITHUB_TOKEN"]
repo_owner = "oppia"
Expand Down