Skip to content

Commit

Permalink
feature paused recurring contributions in active (#558)
Browse files Browse the repository at this point in the history
  • Loading branch information
znarf authored Apr 16, 2024
1 parent d00a293 commit b3ece41
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions src/server/controllers/account-contributors.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,25 @@ const contributorsQuery = gqlV2/* GraphQL */ `
createdAt
}
}
pausedRecurringContributions: orders(
searchTerm: $slug
status: PAUSED
orderBy: { field: CREATED_AT, direction: DESC }
) {
totalCount
nodes {
frequency
amount {
value
currency
}
tier {
slug
name
}
createdAt
}
}
latestContributions: transactions(
limit: 1
kind: CONTRIBUTION
Expand Down Expand Up @@ -79,16 +98,19 @@ const contributorsQuery = gqlV2/* GraphQL */ `
}
`;

const activeRecurringContribution = (m) =>
get(m, 'account.activeRecurringContributions.nodes[0]') || get(m, 'account.pausedRecurringContributions.nodes[0]');

const csvMapping = {
contributorUrl: (m) => `${process.env.WEBSITE_URL}/${m.account.slug}`,
contributorName: 'account.name',
contributorType: 'account.type',
totalContributions: 'totalDonations.value',
currency: 'totalDonations.currency',
activeRecurringContribution: (m) => (m.account.activeRecurringContributions.nodes.length ? 'yes' : 'no'),
activeRecurringContributionTier: (m) => get(m, 'account.activeRecurringContributions.nodes[0].tier.slug'), // Or name?
activeRecurringContributionAmount: (m) => get(m, 'account.activeRecurringContributions.nodes[0].amount.value'), // Currency?
activeRecurringContributionFrequency: (m) => get(m, 'account.activeRecurringContributions.nodes[0].frequency'),
activeRecurringContribution: (m) => (activeRecurringContribution(m) ? 'yes' : 'no'),
activeRecurringContributionTier: (m) => get(activeRecurringContribution(m), 'tier.slug'),
activeRecurringContributionAmount: (m) => get(activeRecurringContribution(m), 'amount.value'), // Currency?
activeRecurringContributionFrequency: (m) => get(activeRecurringContribution(m), 'frequency'),
firstContributionDate: (m) =>
m.account.firstContributions.nodes[0] &&
moment.utc(m.account.firstContributions.nodes[0].createdAt).format('YYYY-MM-DD'),
Expand Down

0 comments on commit b3ece41

Please sign in to comment.