P2P campaign creator email is shown in campaign

This commit is contained in:
Eric Schultz 2019-01-22 15:06:49 -06:00 committed by Eric Schultz
parent ed28ca9a82
commit 3d4e65059b
2 changed files with 17 additions and 1 deletions

View file

@ -19,7 +19,8 @@ const root = state => {
h('th', 'Name'),
h('th', 'Total'),
h('th', 'Gift options'),
h('th', 'Latest gift')
h('th', 'Latest gift'),
h('th', 'Campaign creator')
]),
thunk(trs, supporters.get('data')),
]),
@ -52,6 +53,11 @@ const supporterRow = supporter =>
, h('td', '$' + utils.cents_to_dollars(supporter.get('total_raised'))),
h('td', supporter.get('campaign_gift_names').toJS().join(', ')),
h('td', supporter.get('latest_gift')),
h('td', {}, supporter.get('campaign_creator_emails').toJS().map(
function(i, index, array) {
return h('a', {href: `mailto:${i}`},
i + ((i < (array.length - 1)) ? ", " : ""))
})),
])
module.exports = {

View file

@ -18,6 +18,15 @@ module QuerySupporters
.where('payments.donation_id = donations.id')
.order_by('payments.created_at ASC')
.limit(1).parse, true)
.join(Qx.select('id, profile_id').from('campaigns')
.where("id IN (#{QueryCampaigns
.get_campaign_and_children(campaign_id)
.parse})").as('campaigns').parse,
'donations.campaign_id=campaigns.id')
.join(Qx.select('users.id, profiles.id AS profiles_id, users.email')
.from('users')
.add_join('profiles', 'profiles.user_id = users.id')
.as("users").parse, "users.profiles_id=campaigns.profile_id")
.where("supporters.nonprofit_id=$id", id: np_id)
.where("donations.campaign_id IN (#{QueryCampaigns
.get_campaign_and_children(campaign_id)
@ -49,6 +58,7 @@ module QuerySupporters
'SUM(payments.gross_amount) AS total_raised',
'ARRAY_AGG(DISTINCT campaign_gift_options.name) AS campaign_gift_names',
'DATE(MAX(donations.created_at)) AS latest_gift',
'ARRAY_AGG(DISTINCT users.email) AS campaign_creator_emails'
).limit(limit).offset(offset)
)