Skip to content

Commit 0bbfdc4

Browse files
committed
reset top ranking issues
1 parent 1c65dca commit 0bbfdc4

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import json
2+
import os
3+
import pathlib
4+
from collections import defaultdict
5+
from datetime import datetime, timedelta
6+
from typing import Optional
7+
8+
from github import Github
9+
from github.Issue import Issue
10+
from github.Repository import Repository
11+
from pytz import timezone
12+
13+
14+
def main():
15+
start_time: datetime = datetime.now()
16+
17+
# GitHub Workflow will pass in the token as an environment variable,
18+
# but we can place it in our env when running the script locally, for convenience
19+
local_github_token: str | None = None
20+
github_token: str | None = local_github_token or os.getenv("GITHUB_ACCESS_TOKEN")
21+
github = Github(github_token)
22+
23+
# Rate limiting
24+
remaining_requests_before: int = github.rate_limiting[0]
25+
print(f"Remaining requests before: {remaining_requests_before}")
26+
27+
28+
repo_name: str = "pvlib/pvlib-python"
29+
repository: Repository = github.get_repo(repo_name)
30+
31+
# Get sorted issues
32+
query: str = f'repo:{repository.full_name} is:open is:issue sort:reactions-+1-desc'
33+
issues = github.search_issues(query)
34+
35+
# Format markdown
36+
ranked_issues = []
37+
for i, issue in enumerate(issues):
38+
markdown_bullet_point: str = (
39+
f"{issue.html_url} ({issue._rawData["reactions"]["+1"]} :thumbsup:)"
40+
)
41+
42+
markdown_bullet_point = f"{i + 1}. {markdown_bullet_point}"
43+
ranked_issues.append(markdown_bullet_point)
44+
45+
if i >= 19:
46+
break
47+
48+
49+
# edit top issues
50+
top_issues_card: Issue = repository.get_issue(number=2196)
51+
header = "Top Ranking Issues"
52+
new_body = header + "\n" + "\n".join(ranked_issues)
53+
top_issues_card.edit(
54+
body=new_body
55+
)
56+
57+
print(top_issues_card.body)
58+
59+
run_duration: timedelta = datetime.now() - start_time
60+
print(run_duration)
61+
62+
63+
64+
if __name__ == "__main__":
65+
main()
66+
print('done')
67+
68+
# TODO: Sort label output into core and non core sections

0 commit comments

Comments
 (0)