Sponsorship auto-generate v0.1.5
This commit is contained in:
@@ -12,34 +12,34 @@ def fetch_sponsors():
|
|||||||
"Accept": "application/vnd.github.v4+json",
|
"Accept": "application/vnd.github.v4+json",
|
||||||
}
|
}
|
||||||
|
|
||||||
# GraphQL query to fetch sponsors
|
# GraphQL query to fetch public sponsors
|
||||||
graphql_query = """
|
graphql_query = """
|
||||||
{
|
{
|
||||||
user(login: "jokob-sk") {
|
user(login: "jokob-sk") {
|
||||||
sponsorshipsAsMaintainer(first: 100, orderBy: {field: CREATED_AT, direction: ASC}, includePrivate: true) {
|
sponsorshipsAsMaintainer(first: 100, orderBy: {field: CREATED_AT, direction: ASC}, includePrivate: true) {
|
||||||
totalCount
|
totalCount
|
||||||
pageInfo {
|
pageInfo {
|
||||||
endCursor
|
endCursor
|
||||||
}
|
|
||||||
nodes {
|
|
||||||
sponsorEntity {
|
|
||||||
... on User {
|
|
||||||
name
|
|
||||||
login
|
|
||||||
url
|
|
||||||
}
|
}
|
||||||
... on Organization {
|
nodes {
|
||||||
name
|
sponsorEntity {
|
||||||
url
|
... on User {
|
||||||
login
|
name
|
||||||
|
login
|
||||||
|
url
|
||||||
|
}
|
||||||
|
... on Organization {
|
||||||
|
name
|
||||||
|
url
|
||||||
|
login
|
||||||
|
}
|
||||||
|
}
|
||||||
|
createdAt
|
||||||
|
privacyLevel
|
||||||
|
tier {
|
||||||
|
monthlyPriceInCents
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
createdAt
|
|
||||||
privacyLevel
|
|
||||||
tier {
|
|
||||||
monthlyPriceInCents
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -48,7 +48,6 @@ def fetch_sponsors():
|
|||||||
response = requests.post(graphql_url, json={"query": graphql_query}, headers=headers)
|
response = requests.post(graphql_url, json={"query": graphql_query}, headers=headers)
|
||||||
data = response.json()
|
data = response.json()
|
||||||
|
|
||||||
|
|
||||||
print(f"Debug GraphQL query result: {data}")
|
print(f"Debug GraphQL query result: {data}")
|
||||||
|
|
||||||
if "errors" in data:
|
if "errors" in data:
|
||||||
@@ -59,27 +58,34 @@ def fetch_sponsors():
|
|||||||
sponsors = []
|
sponsors = []
|
||||||
|
|
||||||
for sponsorship in sponsorships:
|
for sponsorship in sponsorships:
|
||||||
sponsor_entity = sponsorship["sponsorEntity"]
|
|
||||||
created_at = datetime.strptime(sponsorship["createdAt"], "%Y-%m-%dT%H:%M:%SZ")
|
|
||||||
privacy_level = sponsorship["privacyLevel"]
|
privacy_level = sponsorship["privacyLevel"]
|
||||||
monthly_price = sponsorship["tier"]["monthlyPriceInCents"]
|
|
||||||
|
|
||||||
sponsor = {
|
# Only include sponsors with privacyLevel set to "PUBLIC"
|
||||||
"name": sponsor_entity.get("name"),
|
if privacy_level == "PUBLIC":
|
||||||
"login": sponsor_entity["login"],
|
sponsor_entity = sponsorship["sponsorEntity"]
|
||||||
"url": sponsor_entity["url"],
|
created_at = datetime.strptime(sponsorship["createdAt"], "%Y-%m-%dT%H:%M:%SZ")
|
||||||
"created_at": created_at,
|
|
||||||
"privacy_level": privacy_level,
|
|
||||||
"monthly_price": monthly_price,
|
|
||||||
}
|
|
||||||
|
|
||||||
sponsors.append(sponsor)
|
# Check if tier is not None before accessing its properties
|
||||||
|
tier = sponsorship.get("tier", {})
|
||||||
|
monthly_price = tier.get("monthlyPriceInCents") if tier else None
|
||||||
|
|
||||||
print("All Sponsors:")
|
sponsor = {
|
||||||
|
"name": sponsor_entity.get("name"),
|
||||||
|
"login": sponsor_entity["login"],
|
||||||
|
"url": sponsor_entity["url"],
|
||||||
|
"created_at": created_at,
|
||||||
|
"privacy_level": privacy_level,
|
||||||
|
"monthly_price": monthly_price,
|
||||||
|
}
|
||||||
|
|
||||||
|
sponsors.append(sponsor)
|
||||||
|
|
||||||
|
print("Public Sponsors:")
|
||||||
print(sponsors)
|
print(sponsors)
|
||||||
|
|
||||||
return {"sponsors": sponsors}
|
return {"sponsors": sponsors}
|
||||||
|
|
||||||
|
|
||||||
def generate_sponsors_table(sponsors):
|
def generate_sponsors_table(sponsors):
|
||||||
sponsors_table = "| All Sponsors |\n|---|\n"
|
sponsors_table = "| All Sponsors |\n|---|\n"
|
||||||
for sponsor in sponsors:
|
for sponsor in sponsors:
|
||||||
|
|||||||
Reference in New Issue
Block a user