Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a7cc25e

Browse files
authored
🔧 Update FastAPI People GitHub Sponsors order (#2620)
1 parent d2eb4a7 commit a7cc25e

2 files changed

Lines changed: 39 additions & 12 deletions

File tree

‎.github/actions/people/app/main.py‎

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import logging
22
import subprocess
33
import sys
4-
from collections import Counter
4+
from collections import Counter, defaultdict
55
from datetime import datetime, timedelta, timezone
66
from pathlib import Path
7-
from typing import Container, Dict, List, Optional, Set
7+
from typing import Container, DefaultDict, Dict, List, Optional, Set
88

99
import httpx
1010
import yaml
@@ -375,7 +375,7 @@ def get_contributors(settings: Settings):
375375
return contributors, commentors, reviewers, authors
376376

377377

378-
def get_individual_sponsors(settings: Settings, max_individual_sponsor: int = 5):
378+
def get_individual_sponsors(settings: Settings):
379379
nodes: List[SponsorshipAsMaintainerNode] = []
380380
edges = get_graphql_sponsor_edges(settings=settings)
381381

@@ -385,12 +385,12 @@ def get_individual_sponsors(settings: Settings, max_individual_sponsor: int = 5)
385385
last_edge = edges[-1]
386386
edges = get_graphql_sponsor_edges(settings=settings, after=last_edge.cursor)
387387

388-
entities: Dict[str, SponsorEntity] = {}
388+
tiers: DefaultDict[float, Dict[str, SponsorEntity]] = defaultdict(dict)
389389
for node in nodes:
390-
if node.tier.monthlyPriceInDollars > max_individual_sponsor:
391-
continue
392-
entities[node.sponsorEntity.login] = node.sponsorEntity
393-
return entities
390+
tiers[node.tier.monthlyPriceInDollars][
391+
node.sponsorEntity.login
392+
] = node.sponsorEntity
393+
return tiers
394394

395395

396396
def get_top_users(
@@ -475,19 +475,30 @@ def get_top_users(
475475
skip_users=skip_users,
476476
)
477477

478-
sponsors_by_login = get_individual_sponsors(settings=settings)
479-
sponsors = []
480-
for login, sponsor in sponsors_by_login.items():
481-
sponsors.append(
478+
tiers = get_individual_sponsors(settings=settings)
479+
sponsors_50 = []
480+
for login, sponsor in tiers[50].items():
481+
sponsors_50.append(
482482
{"login": login, "avatarUrl": sponsor.avatarUrl, "url": sponsor.url}
483483
)
484+
keys = list(tiers.keys())
485+
keys.sort(reverse=True)
486+
sponsors = []
487+
for key in keys:
488+
if key >= 50:
489+
continue
490+
for login, sponsor in tiers[key].items():
491+
sponsors.append(
492+
{"login": login, "avatarUrl": sponsor.avatarUrl, "url": sponsor.url}
493+
)
484494

485495
people = {
486496
"maintainers": maintainers,
487497
"experts": experts,
488498
"last_month_active": last_month_active,
489499
"top_contributors": top_contributors,
490500
"top_reviewers": top_reviewers,
501+
"sponsors_50": sponsors_50,
491502
"sponsors": sponsors,
492503
}
493504
people_path = Path("./docs/en/data/people.yml")

‎docs/en/docs/fastapi-people.md‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,22 @@ They are supporting my work with **FastAPI** (and others), mainly through <a hre
130130
{% endfor %}
131131
{% endif %}
132132

133+
{% if people %}
134+
{% if people.sponsors_50 %}
135+
136+
### Bronze Sponsors
137+
138+
<div class="user-list user-list-center">
139+
{% for user in people.sponsors_50 %}
140+
141+
<div class="user"><a href="{{ user.url }}" target="_blank"><div class="avatar-wrapper"><img src="{{ user.avatarUrl }}"/></div><div class="title">@{{ user.login }}</div></a></div>
142+
{% endfor %}
143+
144+
</div>
145+
146+
{% endif %}
147+
{% endif %}
148+
133149
### Individual Sponsors
134150

135151
{% if people %}

0 commit comments

Comments
 (0)