mirror of
https://github.com/LemmyNet/joinlemmy-site.git
synced 2024-11-22 04:11:15 +00:00
Adding donation platform fetching. Fixes #248
This commit is contained in:
parent
4bd4d7a0c4
commit
20b9d73a6b
6 changed files with 82 additions and 13 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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");
|
||||
|
|
17
src/shared/donation_stats.ts
Normal file
17
src/shared/donation_stats.ts
Normal file
|
@ -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,
|
||||
},
|
||||
];
|
48
update_donations.mjs
Normal file
48
update_donations.mjs
Normal file
|
@ -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);
|
Loading…
Reference in a new issue