Skip to content

Commit aaa17f0

Browse files
committed
feat: Fetch membership count from MAGIC (#2957)
Signed-off-by: Justin Ehrenhofer <[email protected]>
1 parent 426c5a2 commit aaa17f0

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

docs/about/donate.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ MAGIC Grants is our fiscal host, and their custom, open-source donation platform
4444
Privacy Guides would not be possible without these individuals who generously donate on a monthly or yearly basis. (1)
4545
{ .annotate }
4646

47-
1. If you [become a member](https://donate.magicgrants.org/privacyguides/membership) and [link your donation](https://discuss.privacyguides.net/t/getting-your-member-flair-on-the-forum/25453) to your forum account, you're automatically added here with a link to your profile and avatar to show your support for Privacy Guides. If you link your forum account but don't set your flair or title, you'll be a silent +1. You can change your visibility any time. This chart is updated upon each website release.
47+
1. If you [become a member](https://donate.magicgrants.org/privacyguides/membership) and [link your donation](https://discuss.privacyguides.net/t/getting-your-member-flair-on-the-forum/25453) to your forum account, you're automatically added here with a link to your profile and avatar to show your support for Privacy Guides. If you don't make your membership public on the forum, you'll be a silent +1. You can change your visibility any time. This chart is updated upon each website release.
4848

4949
<div class="mdx-donors" data-mdx-component="donors">
5050
<div class="mdx-donors__list">

generate-members.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
raise KeyError("Response JSON does not contain 'members' key")
1919

2020
members = members_data['members']
21+
public_members_count = 0
2122
private_members_count = 0
2223

2324
html_output = ""
@@ -30,8 +31,7 @@
3031
avatar_url = f"https://discuss.privacyguides.net{avatar_template.replace('{size}', '128')}"
3132
profile_url = f"https://discuss.privacyguides.net/u/{username}"
3233
html_output += f'<a href="{profile_url}" target="_blank" title="@{username}" class="mdx-donors__item"><img loading="lazy" src="{avatar_url}"></a>'
33-
else:
34-
private_members_count += 1
34+
public_members_count += 1
3535

3636
# print(html_output)
3737

@@ -84,7 +84,16 @@
8484
url = sponsor_entity['url']
8585
html_output += f'<a href="{url}" title="@{login}" rel="ugc nofollow" target="_blank" class="mdx-donors__item"><img loading="lazy" src="{avatar_url}&size=120"></a>'
8686

87-
private_members_count += 6
87+
# Fetch the number of active members from the Magic Grants API
88+
magic_grants_url = "https://donate.magicgrants.org/api/active-members?fund=privacyguides"
89+
magic_grants_response = requests.get(magic_grants_url)
90+
magic_grants_data = magic_grants_response.json()
91+
92+
if 'members_count' not in magic_grants_data:
93+
raise KeyError("Response JSON does not contain 'members_count' key")
94+
95+
private_members_count += magic_grants_data['members_count']
96+
private_members_count -= public_members_count
8897

8998
# Append the count of private members
9099
if private_members_count > 0:

0 commit comments

Comments
 (0)