Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add thanks.dev #655

Merged
merged 5 commits into from
Oct 29, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 19 additions & 18 deletions tools/fetch-sponsors.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const knownOneTimers = new Set([
const { ESLINT_GITHUB_TOKEN } = process.env;

if (!ESLINT_GITHUB_TOKEN) {
throw new Error("Missing ESLINT_GITHUB_TOKEN.");
// throw new Error("Missing ESLINT_GITHUB_TOKEN.");
amareshsm marked this conversation as resolved.
Show resolved Hide resolved
}

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -414,28 +414,29 @@ async function fetchThanksDevData() {
);
}

const sponsors = Object.values(payload.donors).reduce(
(accumulator, { name, login, avatar, url, payments }) => {
const sponsors = Object.values(payload.donors)
.filter(({ payments }) => {
const lastPayment = payments.at(-1);

const paymentMonth = new Date(lastPayment.month).getMonth();
const currentMonth = new Date().getMonth();

if (paymentMonth === currentMonth) {
accumulator.push({
name: name ?? login,
url: fixUrl(url),
image: avatar,
monthlyDonation: Number(lastPayment.amount),
source: "thanksdev",
tier: getTierSlug(lastPayment.amount),
});
}

return accumulator;
},
[],
);
const paymentYear = new Date(lastPayment.month).getFullYear();
const currentYear = new Date().getFullYear();
amareshsm marked this conversation as resolved.
Show resolved Hide resolved

return paymentMonth === currentMonth && paymentYear === currentYear;
})
.map(({ name, login, avatar, url, payments }) => {
const { amount } = payments.at(-1);
return {
name: name ?? login,
url: fixUrl(url),
image: avatar,
monthlyDonation: Number(amount),
harish-sethuraman marked this conversation as resolved.
Show resolved Hide resolved
source: "thanks.dev",
tier: getTierSlug(amount),
};
});

return {
sponsors,
Expand Down