Skip to content

Commit 1de836b

Browse files
authored
Filter and categorize sponsors/backers (#4596)
1 parent e9860b3 commit 1de836b

File tree

4 files changed

+21
-24
lines changed

4 files changed

+21
-24
lines changed

docs/_data/blocklist.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"mochajs",
1111
"my-true-media",
1212
"open-apk-file",
13-
"pfannen-test",
1413
"thetoy",
1514
"trust-my-paper",
1615
"writemypaper4me",

docs/_data/supporters.js

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#!/usr/bin/env node
22

33
/**
4-
* This script gathers metadata for supporters of Mocha from OpenCollective's API by
5-
* aggregating order ("donation") information.
4+
* This script gathers metadata for active supporters of Mocha from OpenCollective's
5+
* API by aggregating order ("donation") information.
66
*
7-
* It's intended to be used with 11ty, but can be run directly. Running directly
7+
* It's intended to be used with 11ty, but can be run directly. Running directly
88
* enables debug output.
99
*
1010
* - gathers logo/avatar images (they are always pngs)
1111
* - gathers links
12-
* - sorts by total contributions and tier
12+
* - sorts by tier and total contributions
1313
* - validates images
1414
* - writes images to a temp dir
1515
* @see https://docs.opencollective.com/help/contributing/development/api
@@ -28,7 +28,7 @@ const blocklist = new Set(require('./blocklist.json'));
2828
* In addition to the blocklist, any account slug matching this regex will not
2929
* be displayed on the website.
3030
*/
31-
const BLOCKED_STRINGS = /(?:vpn|[ck]a[sz]ino|seo|slots|gambl(?:e|ing)|crypto)/i;
31+
const BLOCKED_STRINGS = /(?:[ck]a[sz]ino|seo|slots|gambl(?:e|ing)|crypto)/i;
3232

3333
/**
3434
* Add a few Categories exposed by Open Collective to help moderation
@@ -48,8 +48,8 @@ const BLOCKED_CATEGORIES = [
4848
*/
4949
const API_ENDPOINT = 'https://api.opencollective.com/graphql/v2';
5050

51-
const SPONSOR_TIER = 'sponsor';
52-
const BACKER_TIER = 'backer';
51+
const SPONSOR_TIER = 'sponsors';
52+
const BACKER_TIER = 'backers';
5353

5454
// if this percent of fetches completes, the build will pass
5555
const PRODUCTION_SUCCESS_THRESHOLD = 0.8;
@@ -58,7 +58,7 @@ const SUPPORTER_IMAGE_PATH = resolve(__dirname, '../images/supporters');
5858

5959
const SUPPORTER_QUERY = `query account($limit: Int, $offset: Int, $slug: String) {
6060
account(slug: $slug) {
61-
orders(limit: $limit, offset: $offset) {
61+
orders(limit: $limit, offset: $offset, status: ACTIVE, filter: INCOMING) {
6262
limit
6363
offset
6464
totalCount
@@ -73,9 +73,8 @@ const SUPPORTER_QUERY = `query account($limit: Int, $offset: Int, $slug: String)
7373
type
7474
categories
7575
}
76-
totalDonations {
77-
value
78-
}
76+
tier { slug }
77+
totalDonations { value }
7978
createdAt
8079
}
8180
}
@@ -93,10 +92,11 @@ const nodeToSupporter = node => ({
9392
website: node.fromAccount.website,
9493
imgUrlMed: node.fromAccount.imgUrlMed,
9594
imgUrlSmall: node.fromAccount.imgUrlSmall,
96-
firstDonation: node.createdAt,
97-
totalDonations: node.totalDonations.value * 100,
9895
type: node.fromAccount.type,
99-
categories: node.fromAccount.categories
96+
categories: node.fromAccount.categories,
97+
tier: (node.tier && node.tier.slug) || BACKER_TIER,
98+
totalDonations: node.totalDonations.value * 100,
99+
firstDonation: node.createdAt
100100
});
101101

102102
const fetchImage = process.env.MOCHA_DOCS_SKIP_IMAGE_DOWNLOAD
@@ -198,14 +198,13 @@ const getSupporters = async () => {
198198
// determine which url to use depending on tier
199199
.reduce(
200200
(supporters, supporter) => {
201-
if (supporter.type === 'INDIVIDUAL') {
201+
if (supporter.tier === BACKER_TIER) {
202202
if (supporter.name !== 'anonymous') {
203203
supporters[BACKER_TIER] = [
204204
...supporters[BACKER_TIER],
205205
{
206206
...supporter,
207-
avatar: encodeURI(supporter.imgUrlSmall),
208-
tier: BACKER_TIER
207+
avatar: encodeURI(supporter.imgUrlSmall)
209208
}
210209
];
211210
}
@@ -214,8 +213,7 @@ const getSupporters = async () => {
214213
...supporters[SPONSOR_TIER],
215214
{
216215
...supporter,
217-
avatar: encodeURI(supporter.imgUrlMed),
218-
tier: SPONSOR_TIER
216+
avatar: encodeURI(supporter.imgUrlMed)
219217
}
220218
];
221219
}

docs/_includes/supporters.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Use Mocha at Work? Ask your manager or marketing team if they'd help [support](https://opencollective.com/mochajs#support) our project. Your company's logo will also be displayed on [npmjs.com](http://npmjs.com/package/mocha) and our [GitHub repository](https://github.com/mochajs/mocha#sponsors).
44

55
<ul class="image-list" id="sponsors">
6-
{%- for supporter in supporters.sponsor -%}
6+
{%- for supporter in supporters.sponsors -%}
77
<li>
88
{%- if supporter.website -%}
99
<a href="{{ supporter.website }}" target="_blank" rel="noopener">
@@ -21,7 +21,7 @@ Use Mocha at Work? Ask your manager or marketing team if they'd help [support](h
2121
Find Mocha helpful? Become a [backer](https://opencollective.com/mochajs#support) and support Mocha with a monthly donation.
2222

2323
<ul class="image-list faded-images" id="backers">
24-
{%- for supporter in supporters.backer -%}
24+
{%- for supporter in supporters.backers -%}
2525
<li>
2626
{%- if supporter.website -%}
2727
<a href="{{ supporter.website }}" target="_blank" rel="noopener">

docs/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ Mocha is a feature-rich JavaScript test framework running on [Node.js][] and in
88

99
<nav class="badges">
1010
<a href="https://gitter.im/mochajs/mocha"><img src="/images/join-chat.svg" height="18" alt="Gitter"></a>
11-
<a href="#sponsors"><img src="https://opencollective.com/mochajs/sponsors/badge.svg" height="18" alt="OpenCollective sponsors"></a>
12-
<a href="#backers"><img src="https://opencollective.com/mochajs/backers/badge.svg" height="18" alt="OpenCollective backers"></a>
11+
<a href="#sponsors"><img src="https://opencollective.com/mochajs/tiers/sponsors/badge.svg" height="18" alt="OpenCollective sponsors"></a>
12+
<a href="#backers"><img src="https://opencollective.com/mochajs/tiers/backers/badge.svg" height="18" alt="OpenCollective backers"></a>
1313
</nav>
1414

1515
{% include supporters.md %}

0 commit comments

Comments
 (0)