r83664 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83663‎ | r83664 | r83665 >
Date:19:54, 10 March 2011
Author:rfaulk
Status:deferred
Tags:
Comment:
Adding first donation fields to Major Gifts reporting
Modified paths:
  • /trunk/fundraiser-statistics/fundraiser-scripts/query_store.py (modified) (history)
  • /trunk/fundraiser-statistics/fundraiser-scripts/sql/report_ecomm_by_amount.sql (modified) (history)

Diff [purge]

Index: trunk/fundraiser-statistics/fundraiser-scripts/sql/report_ecomm_by_amount.sql
@@ -7,11 +7,14 @@
88 civicrm.civicrm_contact.last_name as last_name,
99 civicrm.civicrm_country.name as name,
1010 civicrm.civicrm_country.iso_code as iso_code,
11 -converted_amount as amount
 11+converted_amount as amount,
 12+if(first_don.first_don_date < ecomm.stamp, 'no','yes') as is_first_donation,
 13+first_don.first_don_date as date_of_first
1214
1315
1416 from
1517 (
 18+
1619 select
1720 DATE_FORMAT(receive_date, '%sY-%sm-%sd %sH') as stamp,
1821 civicrm.civicrm_contribution.id,
@@ -26,6 +29,24 @@
2730 join civicrm.civicrm_address on civicrm.civicrm_contact.id = civicrm.civicrm_address.contact_id
2831 join civicrm.civicrm_country on civicrm.civicrm_address.country_id = civicrm.civicrm_country.id
2932
30 -where ecomm.converted_amount >= 100
 33+left join
 34+
 35+(select
 36+
 37+first_name,
 38+last_name,
 39+min(receive_date) as first_don_date
 40+
 41+from civicrm.civicrm_contribution left join civicrm.public_reporting on civicrm.civicrm_contribution.id = civicrm.public_reporting.contribution_id
 42+join civicrm.civicrm_contact on civicrm.public_reporting.contribution_id = civicrm.civicrm_contact.id
 43+join civicrm.civicrm_address on civicrm.civicrm_contact.id = civicrm.civicrm_address.contact_id
 44+join civicrm.civicrm_country on civicrm.civicrm_address.country_id = civicrm.civicrm_country.id
 45+where receive_date < '%s'
 46+group by 1,2) as first_don
 47+
 48+on first_don.first_name = civicrm.civicrm_contact.first_name and first_don.last_name = civicrm.civicrm_contact.last_name
 49+
 50+
 51+where ecomm.converted_amount >= 100
 52+
3153 group by 1;
32 -
Index: trunk/fundraiser-statistics/fundraiser-scripts/query_store.py
@@ -122,7 +122,7 @@
123123 elif query_name == 'report_ecomm_by_amount':
124124 start_time = args[0]
125125 end_time = args[1]
126 - sql_stmnt = sql_stmnt % ('%', '%', '%', '%', start_time, end_time)
 126+ sql_stmnt = sql_stmnt % ('%', '%', '%', '%', start_time, end_time, end_time)
127127
128128 elif query_name == 'report_ecomm_by_contact':
129129 where_str = args[0]
@@ -145,7 +145,7 @@
146146 if query_name == 'report_contribution_tracking':
147147 return ['Time','Banner','Landing Page','Campaign','Converted Amount', 'Suffix']
148148 elif query_name == 'report_ecomm_by_amount':
149 - return ['Timestamp','First Name','Last Name','Country','ISO Code', 'Amount']
 149+ return ['Timestamp','First Name','Last Name','Country','ISO Code', 'Amount', 'First Donation?', 'Date of First']
150150 elif query_name == 'report_ecomm_by_contact':
151151 return ['Timestamp','First Name','Last Name','Country','ISO Code', 'Amount']
152152 else:

Status & tagging log