From aaa17f0ebf72df107c2118a90c8001370e7e9272 Mon Sep 17 00:00:00 2001 From: Jonah Aragon Date: Fri, 14 Mar 2025 14:34:21 -0700 Subject: [PATCH] feat: Fetch membership count from MAGIC (#2957) Signed-off-by: Justin Ehrenhofer --- docs/about/donate.md | 2 +- generate-members.py | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/docs/about/donate.md b/docs/about/donate.md index 76fc854f..b19686a1 100644 --- a/docs/about/donate.md +++ b/docs/about/donate.md @@ -44,7 +44,7 @@ MAGIC Grants is our fiscal host, and their custom, open-source donation platform Privacy Guides would not be possible without these individuals who generously donate on a monthly or yearly basis. (1) { .annotate } -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. +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.
diff --git a/generate-members.py b/generate-members.py index 4b4669df..6fbe6577 100644 --- a/generate-members.py +++ b/generate-members.py @@ -18,6 +18,7 @@ if 'members' not in members_data: raise KeyError("Response JSON does not contain 'members' key") members = members_data['members'] +public_members_count = 0 private_members_count = 0 html_output = "" @@ -30,8 +31,7 @@ for member in members: avatar_url = f"https://discuss.privacyguides.net{avatar_template.replace('{size}', '128')}" profile_url = f"https://discuss.privacyguides.net/u/{username}" html_output += f'' - else: - private_members_count += 1 + public_members_count += 1 # print(html_output) @@ -84,7 +84,16 @@ for sponsor in sponsors: url = sponsor_entity['url'] html_output += f'' -private_members_count += 6 +# Fetch the number of active members from the Magic Grants API +magic_grants_url = "https://donate.magicgrants.org/api/active-members?fund=privacyguides" +magic_grants_response = requests.get(magic_grants_url) +magic_grants_data = magic_grants_response.json() + +if 'members_count' not in magic_grants_data: + raise KeyError("Response JSON does not contain 'members_count' key") + +private_members_count += magic_grants_data['members_count'] +private_members_count -= public_members_count # Append the count of private members if private_members_count > 0: