Skip to content

Commit 7ea55b3

Browse files
authored
[skip ci] Update fetch-sponsors.py
1 parent 3ce5b64 commit 7ea55b3

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

scripts/fetch-sponsors.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,26 @@ def merge_sponsors(sponsors_list):
5757

5858
return list({"login": k, **v} for k, v in sponsors_dict.items())
5959

60+
def extract_sponsors(data):
61+
org_data = data.get("data", {}).get("organization", {})
62+
if not org_data:
63+
return []
64+
65+
sponsorships = org_data.get("sponsorshipsAsMaintainer", {})
66+
if not sponsorships:
67+
return []
68+
69+
nodes = sponsorships.get("nodes", [])
70+
return [
71+
{
72+
"login": node["sponsorEntity"]["login"],
73+
"avatarUrl": node["sponsorEntity"]["avatarUrl"],
74+
"url": node["sponsorEntity"]["url"],
75+
"amount": node["tier"]["monthlyPriceInCents"]
76+
}
77+
for node in nodes if "sponsorEntity" in node and "tier" in node
78+
]
79+
6080
def main():
6181
github_token = os.getenv("SPONSORS_TOKEN")
6282
if not github_token:
@@ -67,15 +87,7 @@ def main():
6787

6888
for org in orgs:
6989
sponsors_data = fetch_sponsors(github_token, org)
70-
sponsors = [
71-
{
72-
"login": node["sponsorEntity"]["login"],
73-
"avatarUrl": node["sponsorEntity"]["avatarUrl"],
74-
"url": node["sponsorEntity"]["url"],
75-
"amount": node["tier"]["monthlyPriceInCents"]
76-
}
77-
for node in sponsors_data.get("data", {}).get("organization", {}).get("sponsorshipsAsMaintainer", {}).get("nodes", [])
78-
]
90+
sponsors = extract_sponsors(sponsors_data)
7991
all_sponsors.extend(sponsors)
8092

8193
merged_sponsors = merge_sponsors(all_sponsors)

0 commit comments

Comments
 (0)