Skip to content

Commit d9b215d

Browse files
sdiazlordavidberenstein1957pre-commit-ci[bot]
authored
refactor: improve get pop issues (#5135)
# Pull Request Template <!-- Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change. --> Closes #5116 CONSIDERATIONS: - I fixed the planned issues, BUT to order them in descending order, I had to filter by v2. and the open ones (there were old milestones, and if the closed ones are shown, only those will be shown). FOR DISTILABEL UPDATE, the v2 filter should be removed. I removed an API call as I found a key to determine if a member of the org/repo opened the issue (pre-commit should not be additionally added as previously because it only creates PRs, not issues). Locally, with a token with the permissions defined, it correctly removed the members. - I realized that the API call to list the issues also retrieves the pull requests, so I added an if statement to filter them. - I removed unneeded keys. <img width="1402" alt="Screenshot 2024-06-30 at 02 42 51" src="https://github.com/argilla-io/argilla/assets/127759186/5d32ebd9-da3b-4fca-a109-f0c251fe1aa1"> <img width="1402" alt="Screenshot 2024-06-30 at 02 42 38" src="https://github.com/argilla-io/argilla/assets/127759186/57818ef5-933f-4337-8613-9091e5292fa4"> <img width="1402" alt="Screenshot 2024-06-30 at 02 42 44" src="https://github.com/argilla-io/argilla/assets/127759186/4dfaee57-bc6c-4d22-b5cb-d51ceeb1827a"> **Type of change** <!-- Please delete options that are not relevant. Remember to title the PR according to the type of change --> - Refactor (change restructuring the codebase without changing functionality) - Improvement (change adding some improvement to an existing functionality) - Documentation update **How Has This Been Tested** <!-- Please add some reference about how your feature has been tested. --> **Checklist** <!-- Please go over the list and make sure you've taken everything into account --> - I made corresponding changes to the documentation - I confirm My changes generate no new warnings --------- Co-authored-by: David Berenstein <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 9eda5d1 commit d9b215d

File tree

1 file changed

+13
-38
lines changed

1 file changed

+13
-38
lines changed

argilla/docs/scripts/gen_popular_issues.py

Lines changed: 13 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,12 @@ def fetch_data_from_github(repository, auth_token):
3232
"Issue": [],
3333
"State": [],
3434
"Created at": [],
35-
"Closed at": [],
36-
"Last update": [],
37-
"Labels": [],
3835
"Milestone": [],
3936
"Reactions": [],
4037
"Comments": [],
4138
"URL": [],
42-
"Repository": [],
4339
"Author": [],
40+
"Author association": [],
4441
}
4542
)
4643
headers = {"Authorization": f"token {auth_token}", "Accept": "application/vnd.github.v3+json"}
@@ -58,20 +55,19 @@ def fetch_data_from_github(repository, auth_token):
5855
issues = response.json()
5956

6057
for issue in issues:
58+
if "pull_request" in issue:
59+
continue
6160
issues_data.append(
6261
{
6362
"Issue": f"{issue['number']} - {issue['title']}",
6463
"State": issue["state"],
6564
"Created at": issue["created_at"],
66-
"Closed at": issue.get("closed_at", None),
67-
"Last update": issue["updated_at"],
68-
"Labels": [label["name"] for label in issue["labels"]],
6965
"Milestone": (issue.get("milestone") or {}).get("title"),
7066
"Reactions": issue["reactions"]["total_count"],
7167
"Comments": issue["comments"],
7268
"URL": issue["html_url"],
73-
"Repository": repo_name,
7469
"Author": issue["user"]["login"],
70+
"Author association": issue["author_association"],
7571
}
7672
)
7773

@@ -80,53 +76,32 @@ def fetch_data_from_github(repository, auth_token):
8076
return pd.DataFrame(issues_data)
8177

8278

83-
def get_org_members(auth_token):
84-
headers = {"Authorization": f"token {auth_token}", "Accept": "application/vnd.github.v3+json"}
85-
members_list = []
86-
87-
members_url = "https://api.github.com/orgs/argilla-io/members"
88-
89-
if auth_token is None:
90-
return []
91-
92-
while members_url:
93-
response = requests.get(members_url, headers=headers)
94-
members = response.json()
95-
96-
for member in members:
97-
members_list.append(member["login"])
98-
99-
members_list.extend(["pre-commit-ci[bot]"])
100-
101-
members_url = response.links.get("next", {}).get("url", None)
102-
103-
return members_list
104-
105-
10679
with mkdocs_gen_files.open(DATA_PATH, "w") as f:
10780
df = fetch_data_from_github(REPOSITORY, GITHUB_ACCESS_TOKEN)
10881

10982
open_issues = df.loc[df["State"] == "open"]
11083
engagement_df = (
111-
open_issues[["URL", "Issue", "Repository", "Reactions", "Comments"]]
84+
open_issues[["URL", "Issue", "Reactions", "Comments"]]
11285
.sort_values(by=["Reactions", "Comments"], ascending=False)
11386
.head(10)
11487
.reset_index()
11588
)
11689

117-
members = get_org_members(GITHUB_ACCESS_TOKEN)
118-
community_issues = df.loc[~df["Author"].isin(members)]
90+
community_issues = df[df["Author association"] != "MEMBER"]
11991
community_issues_df = (
120-
community_issues[["URL", "Issue", "Repository", "Created at", "Author", "State"]]
92+
community_issues[["URL", "Issue", "Created at", "Author", "State"]]
12193
.sort_values(by=["Created at"], ascending=False)
12294
.head(10)
12395
.reset_index()
12496
)
12597

126-
planned_issues = df.loc[df["Milestone"].notna()]
98+
planned_issues = df[
99+
((df["Milestone"].str.startswith("v2")) & (df["State"] == "open"))
100+
| ((df["Milestone"].str.startswith("2")) & (df["State"] == "open"))
101+
]
127102
planned_issues_df = (
128-
planned_issues[["URL", "Issue", "Repository", "Created at", "Milestone", "State"]]
129-
.sort_values(by=["Milestone"], ascending=False)
103+
planned_issues[["URL", "Issue", "Created at", "Milestone", "State"]]
104+
.sort_values(by=["Milestone"], ascending=True)
130105
.head(10)
131106
.reset_index()
132107
)

0 commit comments

Comments
 (0)