From 1de836bf01dd8d9875912a2e7f193d973604ae3b Mon Sep 17 00:00:00 2001 From: Juerg B <44573692+juergba@users.noreply.github.com> Date: Fri, 12 Mar 2021 07:08:42 +0100 Subject: [PATCH] Filter and categorize sponsors/backers (#4596) --- docs/_data/blocklist.json | 1 - docs/_data/supporters.js | 36 +++++++++++++++++------------------- docs/_includes/supporters.md | 4 ++-- docs/index.md | 4 ++-- 4 files changed, 21 insertions(+), 24 deletions(-) diff --git a/docs/_data/blocklist.json b/docs/_data/blocklist.json index 8093309e23..0e74abf606 100644 --- a/docs/_data/blocklist.json +++ b/docs/_data/blocklist.json @@ -10,7 +10,6 @@ "mochajs", "my-true-media", "open-apk-file", - "pfannen-test", "thetoy", "trust-my-paper", "writemypaper4me", diff --git a/docs/_data/supporters.js b/docs/_data/supporters.js index e227d423a9..cbc12a84c0 100755 --- a/docs/_data/supporters.js +++ b/docs/_data/supporters.js @@ -1,15 +1,15 @@ #!/usr/bin/env node /** - * This script gathers metadata for supporters of Mocha from OpenCollective's API by - * aggregating order ("donation") information. + * This script gathers metadata for active supporters of Mocha from OpenCollective's + * API by aggregating order ("donation") information. * - * It's intended to be used with 11ty, but can be run directly. Running directly + * It's intended to be used with 11ty, but can be run directly. Running directly * enables debug output. * * - gathers logo/avatar images (they are always pngs) * - gathers links - * - sorts by total contributions and tier + * - sorts by tier and total contributions * - validates images * - writes images to a temp dir * @see https://docs.opencollective.com/help/contributing/development/api @@ -28,7 +28,7 @@ const blocklist = new Set(require('./blocklist.json')); * In addition to the blocklist, any account slug matching this regex will not * be displayed on the website. */ -const BLOCKED_STRINGS = /(?:vpn|[ck]a[sz]ino|seo|slots|gambl(?:e|ing)|crypto)/i; +const BLOCKED_STRINGS = /(?:[ck]a[sz]ino|seo|slots|gambl(?:e|ing)|crypto)/i; /** * Add a few Categories exposed by Open Collective to help moderation @@ -48,8 +48,8 @@ const BLOCKED_CATEGORIES = [ */ const API_ENDPOINT = 'https://api.opencollective.com/graphql/v2'; -const SPONSOR_TIER = 'sponsor'; -const BACKER_TIER = 'backer'; +const SPONSOR_TIER = 'sponsors'; +const BACKER_TIER = 'backers'; // if this percent of fetches completes, the build will pass const PRODUCTION_SUCCESS_THRESHOLD = 0.8; @@ -58,7 +58,7 @@ const SUPPORTER_IMAGE_PATH = resolve(__dirname, '../images/supporters'); const SUPPORTER_QUERY = `query account($limit: Int, $offset: Int, $slug: String) { account(slug: $slug) { - orders(limit: $limit, offset: $offset) { + orders(limit: $limit, offset: $offset, status: ACTIVE, filter: INCOMING) { limit offset totalCount @@ -73,9 +73,8 @@ const SUPPORTER_QUERY = `query account($limit: Int, $offset: Int, $slug: String) type categories } - totalDonations { - value - } + tier { slug } + totalDonations { value } createdAt } } @@ -93,10 +92,11 @@ const nodeToSupporter = node => ({ website: node.fromAccount.website, imgUrlMed: node.fromAccount.imgUrlMed, imgUrlSmall: node.fromAccount.imgUrlSmall, - firstDonation: node.createdAt, - totalDonations: node.totalDonations.value * 100, type: node.fromAccount.type, - categories: node.fromAccount.categories + categories: node.fromAccount.categories, + tier: (node.tier && node.tier.slug) || BACKER_TIER, + totalDonations: node.totalDonations.value * 100, + firstDonation: node.createdAt }); const fetchImage = process.env.MOCHA_DOCS_SKIP_IMAGE_DOWNLOAD @@ -198,14 +198,13 @@ const getSupporters = async () => { // determine which url to use depending on tier .reduce( (supporters, supporter) => { - if (supporter.type === 'INDIVIDUAL') { + if (supporter.tier === BACKER_TIER) { if (supporter.name !== 'anonymous') { supporters[BACKER_TIER] = [ ...supporters[BACKER_TIER], { ...supporter, - avatar: encodeURI(supporter.imgUrlSmall), - tier: BACKER_TIER + avatar: encodeURI(supporter.imgUrlSmall) } ]; } @@ -214,8 +213,7 @@ const getSupporters = async () => { ...supporters[SPONSOR_TIER], { ...supporter, - avatar: encodeURI(supporter.imgUrlMed), - tier: SPONSOR_TIER + avatar: encodeURI(supporter.imgUrlMed) } ]; } diff --git a/docs/_includes/supporters.md b/docs/_includes/supporters.md index 59c57306c5..9ee2b520fe 100644 --- a/docs/_includes/supporters.md +++ b/docs/_includes/supporters.md @@ -3,7 +3,7 @@ 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).