r78635 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r78634‎ | r78635 | r78636 >
Date:20:12, 20 December 2010
Author:rfaulk
Status:deferred (Comments)
Tags:
Comment:


select

lp.utm_campaign,
lp.landing_page,
views as views,
total_clicks as clicks,
donations as donations,
amount as amount,
donations / total_clicks as conversion_rate,
donations / views as don_per_view,
amount / views as amt_per_view,
modified_amount / views as amt_per_view_reduced,
max_amt,
pp_don,
cc_don,
pp_don / pp_clicks as paypal_click_thru,
cc_don / cc_clicks as credit_card_click_thru


from

(select
landing_page,
utm_campaign,
count(*) as views

from landing_page

where request_time >= '%s' and request_time < '%s'
and (utm_campaign REGEXP '%s')
group by 1,2) as lp

left join

(select
SUBSTRING_index(substring_index(utm_source, '.', 2),'.',-1) as landing_page,
utm_campaign,
count(*) as total_clicks,
sum(not isnull(contribution_tracking.contribution_id)) as donations,
sum(converted_amount) AS amount,
sum(if(converted_amount > 100, 100, converted_amount)) AS modified_amount, -- truncates donations over 100
max(converted_amount) AS max_amt,
sum(if(right(utm_source,2)='cc',1,0)) as cc_clicks,
sum(if(right(utm_source,2)='cc' and contribution_tracking.contribution_id,1,0)) as cc_don,
sum(if(right(utm_source,2)='pp',1,0)) as pp_clicks,
sum(if(right(utm_source,2)='pp' and contribution_tracking.contribution_id,1,0)) as pp_don


from
drupal.contribution_tracking LEFT JOIN civicrm.public_reporting
ON (contribution_tracking.contribution_id = civicrm.public_reporting.contribution_id)
where ts >= '%s' and ts < '%s'
and (utm_campaign REGEXP '%s')
group by 1,2) as ecomm

on ecomm.landing_page = lp.landing_page and ecomm.utm_campaign = lp.utm_campaign

where views > 100

group by 1,2,3 order by 8 desc;
Modified paths:
  • /trunk/fundraiser-statistics/fundraiser-scripts/fundraiser_reporting.py (modified) (history)
  • /trunk/fundraiser-statistics/fundraiser-scripts/sql/report_LP_metrics.sql (modified) (history)
  • /trunk/fundraiser-statistics/fundraiser-scripts/sql/report_banner_metrics.sql (modified) (history)
  • /trunk/fundraiser-statistics/reporting/landing_page_test.sql (modified) (history)

Diff [purge]

Index: trunk/fundraiser-statistics/fundraiser-scripts/fundraiser_reporting.py
@@ -507,6 +507,10 @@
508508 query_name = 'report_LP_metrics'
509509 elif type == 'BAN':
510510 query_name = 'report_banner_metrics'
 511+ elif type == 'BAN-TEST':
 512+ '[0-9](JA|SA|EA)[0-9]'
 513+ elif type == 'LP-TEST':
 514+ '[0-9](JA|SA|EA)[0-9]'
511515 else:
512516 sys.exit("Invalid type name - must be 'LP' or 'BAN'.")
513517
@@ -524,4 +528,24 @@
525529 self.gen_plot(metrics, times, title, xlabel, ylabel, ranges, subplot_index, query_name + '_' + metric_name + '.png')
526530
527531 return [metrics, times]
528 -
\ No newline at end of file
 532+
 533+
 534+"""
 535+
 536+CLASS :: ^TestReporting^
 537+
 538+This subclass handles reporting on specific tests as defined by a utm campaign.
 539+
 540+"""
 541+
 542+class TestReporting(FundraiserReporting):
 543+
 544+ def run_query(self,start_time, end_time, query_name, metric_name):
 545+ 'report_latest_campaign'
 546+ # select the first row
 547+
 548+
 549+ def gen_plot(self,counts, times, title, xlabel, ylabel, ranges, subplot_index, fname):
 550+
 551+ def run(self, type, metric_name):
 552+
\ No newline at end of file
Index: trunk/fundraiser-statistics/fundraiser-scripts/sql/report_banner_metrics.sql
@@ -37,7 +37,7 @@
3838 count(*) as views
3939 from landing_page
4040 where request_time >= '%s' and request_time < '%s'
41 -and utm_campaign REGEXP 'JA'
 41+and utm_campaign REGEXP '%s'
4242 group by 1,2) as lp
4343
4444 on imp.utm_source = lp.utm_source and imp.hr = lp.hr
@@ -57,7 +57,7 @@
5858 drupal.contribution_tracking LEFT JOIN civicrm.public_reporting
5959 ON (contribution_tracking.contribution_id = civicrm.public_reporting.contribution_id)
6060 where ts >= '%s' and ts < '%s'
61 -and utm_campaign REGEXP 'JA'
 61+and utm_campaign REGEXP '%s'
6262 group by 1,2) as ecomm
6363
6464 on ecomm.banner = lp.utm_source and ecomm.hr = lp.hr
Index: trunk/fundraiser-statistics/fundraiser-scripts/sql/report_LP_metrics.sql
@@ -33,7 +33,7 @@
3434 from landing_page
3535
3636 where request_time >= '%s' and request_time < '%s'
37 -and utm_campaign REGEXP 'JA'
 37+and utm_campaign REGEXP '%s'
3838 group by 1,2) as lp
3939
4040 join
@@ -53,7 +53,7 @@
5454 drupal.contribution_tracking LEFT JOIN civicrm.public_reporting
5555 ON (contribution_tracking.contribution_id = civicrm.public_reporting.contribution_id)
5656 where ts >= '%s' and ts < '%s'
57 -and utm_campaign REGEXP 'JA'
 57+and utm_campaign REGEXP '[0-9](JA|SA|EA)[0-9]'
5858 group by 1,2) as ecomm
5959
6060 on ecomm.landing_page = lp.landing_page and ecomm.hr = lp.hr
Index: trunk/fundraiser-statistics/reporting/landing_page_test.sql
@@ -11,6 +11,7 @@
1212 donations / total_clicks as conversion_rate,
1313 donations / views as don_per_view,
1414 amount / views as amt_per_view,
 15+modified_amount / views as amt_per_view_reduced,
1516 max_amt,
1617 pp_don,
1718 cc_don,
@@ -39,6 +40,7 @@
4041 count(*) as total_clicks,
4142 sum(not isnull(contribution_tracking.contribution_id)) as donations,
4243 sum(converted_amount) AS amount,
 44+sum(if(converted_amount > 100, 100, converted_amount)) AS modified_amount, -- truncates donations over 100
4345 max(converted_amount) AS max_amt,
4446 sum(if(right(utm_source,2)='cc',1,0)) as cc_clicks,
4547 sum(if(right(utm_source,2)='cc' and contribution_tracking.contribution_id,1,0)) as cc_don,

Comments

#Comment by Nikerabbit (talk | contribs)   20:54, 20 December 2010

??? at commit message

Status & tagging log