Skip to content

Commit

Permalink
refact: export emails in contact notation
Browse files Browse the repository at this point in the history
  • Loading branch information
kewitz committed Oct 16, 2024
1 parent 9aae826 commit c679f01
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/server/controllers/hosted-collectives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import gqlV2 from 'graphql-tag';
import { compact, get, pick, toNumber, trim } from 'lodash';
import moment from 'moment';

import { amountAsString, shortDate } from '../lib/formatting';
import { amountAsString, formatContact, shortDate } from '../lib/formatting';
import { graphqlRequest } from '../lib/graphql';
import { applyMapping, parseToBooleanDefaultFalse, parseToBooleanDefaultTrue, splitEnums } from '../lib/utils';
import { logger } from '../logger';
Expand Down Expand Up @@ -173,7 +173,7 @@ const csvMapping = {
approvedAt: (account) => shortDate(account.approvedAt),
hostFeePercent: 'hostFeePercent',
balance: (account) => amountAsString(account.stats.balance),
adminEmails: (account) => compact(account.admins?.nodes.map((member) => member.account?.email)).join(','),
adminEmails: (account) => compact(account.admins?.nodes.map((member) => formatContact(member.account))).join(', '),
adminCount: (account) => account.admins?.totalCount,
firstContributionDate: (account) => shortDate(account.firstContributionReceived?.nodes[0]?.createdAt),
lastContributionDate: (account) => shortDate(account.lastContributionReceived?.nodes[0]?.createdAt),
Expand Down
3 changes: 3 additions & 0 deletions src/server/lib/formatting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ export const accountNameAndLegalName = (account: { name?: string; legalName?: st
};

export const shortDate = (date: string) => moment.utc(date).format('YYYY-MM-DD');

export const formatContact = (contact: { name?: string; email: string }) =>
`${contact.name ? `${contact.name} ` : ''}<${contact.email}>`;

0 comments on commit c679f01

Please sign in to comment.