diff --git a/client/js/campaigns/supporters/index/supporter-table.es6 b/client/js/campaigns/supporters/index/supporter-table.es6 index be8f0404..b5c053b1 100644 --- a/client/js/campaigns/supporters/index/supporter-table.es6 +++ b/client/js/campaigns/supporters/index/supporter-table.es6 @@ -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 = { diff --git a/lib/query/query_supporters.rb b/lib/query/query_supporters.rb index fd92e546..031e6645 100644 --- a/lib/query/query_supporters.rb +++ b/lib/query/query_supporters.rb @@ -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) )