Browse Source

🔧 Update FastAPI People GitHub Sponsors order (#2620)

pull/2621/head
Sebastián Ramírez 4 years ago
committed by GitHub
parent
commit
a7cc25eb11
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 35
      .github/actions/people/app/main.py
  2. 16
      docs/en/docs/fastapi-people.md

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

@ -1,10 +1,10 @@
import logging
import subprocess
import sys
from collections import Counter
from collections import Counter, defaultdict
from datetime import datetime, timedelta, timezone
from pathlib import Path
from typing import Container, Dict, List, Optional, Set
from typing import Container, DefaultDict, Dict, List, Optional, Set
import httpx
import yaml
@ -375,7 +375,7 @@ def get_contributors(settings: Settings):
return contributors, commentors, reviewers, authors
def get_individual_sponsors(settings: Settings, max_individual_sponsor: int = 5):
def get_individual_sponsors(settings: Settings):
nodes: List[SponsorshipAsMaintainerNode] = []
edges = get_graphql_sponsor_edges(settings=settings)
@ -385,12 +385,12 @@ def get_individual_sponsors(settings: Settings, max_individual_sponsor: int = 5)
last_edge = edges[-1]
edges = get_graphql_sponsor_edges(settings=settings, after=last_edge.cursor)
entities: Dict[str, SponsorEntity] = {}
tiers: DefaultDict[float, Dict[str, SponsorEntity]] = defaultdict(dict)
for node in nodes:
if node.tier.monthlyPriceInDollars > max_individual_sponsor:
continue
entities[node.sponsorEntity.login] = node.sponsorEntity
return entities
tiers[node.tier.monthlyPriceInDollars][
node.sponsorEntity.login
] = node.sponsorEntity
return tiers
def get_top_users(
@ -475,12 +475,22 @@ if __name__ == "__main__":
skip_users=skip_users,
)
sponsors_by_login = get_individual_sponsors(settings=settings)
sponsors = []
for login, sponsor in sponsors_by_login.items():
sponsors.append(
tiers = get_individual_sponsors(settings=settings)
sponsors_50 = []
for login, sponsor in tiers[50].items():
sponsors_50.append(
{"login": login, "avatarUrl": sponsor.avatarUrl, "url": sponsor.url}
)
keys = list(tiers.keys())
keys.sort(reverse=True)
sponsors = []
for key in keys:
if key >= 50:
continue
for login, sponsor in tiers[key].items():
sponsors.append(
{"login": login, "avatarUrl": sponsor.avatarUrl, "url": sponsor.url}
)
people = {
"maintainers": maintainers,
@ -488,6 +498,7 @@ if __name__ == "__main__":
"last_month_active": last_month_active,
"top_contributors": top_contributors,
"top_reviewers": top_reviewers,
"sponsors_50": sponsors_50,
"sponsors": sponsors,
}
people_path = Path("./docs/en/data/people.yml")

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

@ -130,6 +130,22 @@ They are supporting my work with **FastAPI** (and others), mainly through <a hre
{% endfor %}
{% endif %}
{% if people %}
{% if people.sponsors_50 %}
### Bronze Sponsors
<div class="user-list user-list-center">
{% for user in people.sponsors_50 %}
<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>
{% endfor %}
</div>
{% endif %}
{% endif %}
### Individual Sponsors
{% if people %}

Loading…
Cancel
Save