diff --git a/.woodpecker.yml b/.woodpecker.yml index d7714df..633dcd7 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -16,7 +16,7 @@ pipeline: prettier_markdown_check: image: tmknom/prettier:3.0.0 commands: - - prettier -c . "!dist" "!lemmy-docs" "!lemmy-translations" "!joinlemmy-translations" "!lemmy-js-client" "!lemmy-stats-crawler" "!src/shared/instance_stats.ts" + - prettier -c . "!dist" "!lemmy-docs" "!lemmy-translations" "!joinlemmy-translations" "!lemmy-js-client" "!lemmy-stats-crawler" "!src/shared/instance_stats.ts" "!src/shared/donation_stats.ts" yarn: image: node:alpine diff --git a/deploy.sh b/deploy.sh index da5f32a..1e36f5f 100755 --- a/deploy.sh +++ b/deploy.sh @@ -4,8 +4,10 @@ ./update_submodules.sh yarn crawl +yarn update-donations git add "src/shared/instance_stats.ts" -git commit -m "Crawl instance statistics" +git add "src/shared/donation_stats.ts" +git commit -m "Crawl and donation instance statistics" # look for unused translations for langfile in joinlemmy-translations/translations/*.json; do diff --git a/package.json b/package.json index c06e69f..60b609c 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "build:prod": "webpack --mode=production", "clean": "yarn run rimraf dist", "crawl": "node crawl.mjs", + "update-donations": "node update_donations.mjs", "lint": "node generate_translations.mjs && tsc --noEmit && eslint --report-unused-disable-directives --ext .js,.ts,.tsx src && prettier --check \"src/**/*.{ts,tsx,js,css,scss}\"", "prebuild:dev": "yarn clean && node generate_translations.mjs && yarn tailwind", "prebuild:prod": "yarn clean && node generate_translations.mjs && yarn tailwind", diff --git a/src/shared/components/donate-definitions.ts b/src/shared/components/donate-definitions.ts index f20f530..a287752 100644 --- a/src/shared/components/donate-definitions.ts +++ b/src/shared/components/donate-definitions.ts @@ -1,3 +1,5 @@ +import { donation_stats } from "../donation_stats"; + export interface Coder { name: string; link?: string; @@ -112,21 +114,20 @@ export const HIGHLIGHTED_SPONSORS = [ // Don't do these until its automated export const GENERAL_SPONSORS = []; -// Updated 2023-10-11 // Monthly counts in EUR const liberapay: FundingPlatform = { - supporterCount: 294, - monthlyEUR: 358.71 * 4.35, -}; - -const patreon: FundingPlatform = { - supporterCount: 473, - monthlyEUR: 1513.57, + supporterCount: donation_stats[0].patrons, + monthlyEUR: donation_stats[0].amount, }; const openCollective: FundingPlatform = { - supporterCount: 275, - monthlyEUR: 10585 / 12, + supporterCount: donation_stats[1].patrons, + monthlyEUR: donation_stats[1].amount, +}; + +const patreon: FundingPlatform = { + supporterCount: donation_stats[2].patrons, + monthlyEUR: donation_stats[2].amount, }; const fundingPlatforms = [liberapay, patreon, openCollective]; @@ -147,7 +148,7 @@ export const MEDIAN_DEV_MONTHLY_EUR = MEDIAN_DEV_SALARY / 12; export const FUNDED_DEVS = TOTAL_RECURRING_MONTHLY_EUR / MEDIAN_DEV_MONTHLY_EUR; // Goal -export const FUNDED_DEV_GOAL = 4; +export const FUNDED_DEV_GOAL = 2; // End fundraiser date export const END_FUNDRAISER_DATE = new Date("2024-12-01"); diff --git a/src/shared/donation_stats.ts b/src/shared/donation_stats.ts new file mode 100644 index 0000000..769cc4e --- /dev/null +++ b/src/shared/donation_stats.ts @@ -0,0 +1,17 @@ +export const donation_stats = [ + { + name_: "liberapay", + patrons: 292, + amount: 1545.9725682543303, + }, + { + name_: "opencollective", + patrons: 274, + amount: 867.060770338, + }, + { + name_: "patreon", + patrons: 490, + amount: 1424.156049036, + }, +]; diff --git a/update_donations.mjs b/update_donations.mjs new file mode 100644 index 0000000..e6c126c --- /dev/null +++ b/update_donations.mjs @@ -0,0 +1,48 @@ +import fs from "fs"; +import fetch from "node-fetch"; + +const donationStatsFile = "src/shared/donation_stats.ts"; + +const USDtoEURUrl = + "https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies/usd/eur.json"; + +const liberaPayUrl = "https://liberapay.com/Lemmy/public.json"; +const openCollectiveUrl = "https://opencollective.com/lemmy.json"; +const patreonUrl = "https://www.patreon.com/api/campaigns/2692831"; + +const usdToEurRes = await fetch(USDtoEURUrl); +const usdToEur = (await usdToEurRes.json()).eur; + +// In weekly USD +const liberaPayRes = await fetch(liberaPayUrl); +const liberaPayData = await liberaPayRes.json(); + +// In yearly USD, decimal +const openCollectiveRes = await fetch(openCollectiveUrl); +const openCollectiveData = await openCollectiveRes.json(); + +// In monthly USD, decimal +const patreonRes = await fetch(patreonUrl); +const patreonData = await patreonRes.json(); + +const donationData = [ + { + name_: "liberapay", + patrons: liberaPayData.npatrons, + amount: Number(liberaPayData.receiving.amount) * 4.348214 * usdToEur, + }, + { + name_: "opencollective", + patrons: openCollectiveData.backersCount, + amount: (Number(openCollectiveData.yearlyIncome) / 100 / 12) * usdToEur, + }, + { + name_: "patreon", + patrons: patreonData.data.attributes.patron_count, + amount: (Number(patreonData.data.attributes.pledge_sum) / 100) * usdToEur, + }, +]; + +let data = `export const donation_stats = \n `; +data += JSON.stringify(donationData, null, 2) + ";"; +fs.writeFileSync(donationStatsFile, data);