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