r86351 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86350‎ | r86351 | r86352 >
Date:22:16, 18 April 2011
Author:rfaulk
Status:deferred
Tags:
Comment:
Added specialized behaviour for campaign totals plotting - defined CampaignIntervalReporting class for this -- also added tunable parameters for plotting, defined in constructor
Modified paths:
  • /trunk/fundraiser-statistics/fundraiser-scripts/classes/DataLoader.py (modified) (history)

Diff [purge]

Index: trunk/fundraiser-statistics/fundraiser-scripts/classes/DataLoader.py
@@ -73,6 +73,8 @@
7474 def __init__(self):
7575 self._query_names_['banner'] = 'report_banner_metrics_minutely'
7676 self._query_names_['LP'] = 'report_LP_metrics_minutely'
 77+ self._query_names_['campaign'] = 'report_campaign_metrics_minutely'
 78+ self._query_names_['campaign_total'] = 'report_campaign_metrics_minutely_total'
7779
7880 def get_sql_filename_for_query(self, query_type):
7981 return self._query_names_[query_type]
@@ -81,17 +83,17 @@
8284 <DESCRIPTION>
8385
8486 INPUT:
85 - start_time -
86 - end_time -
87 - interval -
88 - query_type -
89 - metric_name -
90 - campaign -
 87+ start_time - start timestamp for reporting
 88+ end_time - end timestamp for reporting
 89+ interval - minutely interval at which to report metrics
 90+ query_type - query type: 'banner', 'campaign', 'LP'
 91+ metric_name - the metric to report
 92+ campaign - the campaign on which to select
9193
9294
9395 RETURN:
94 - metrics -
95 - times -
 96+ metrics - dict containing metric measure for each time index for each donation pipeline handle (e.g. banner names)
 97+ times - dict containing time index for each donation pipeline handle (e.g. banner names)
9698 """
9799 def run_query(self, start_time, end_time, interval, query_type, metric_name, campaign):
98100
@@ -119,16 +121,13 @@
120122
121123
122124 """ Load the SQL File & Format """
123 - filename = self._sql_path_ + query_name + '.sql'
 125+ filename = self._sql_path_+ query_name + '.sql'
124126 sql_stmnt = mh.read_sql(filename)
125127
126128 sql_stmnt = QD.format_query(query_name, sql_stmnt, [start_time, end_time, campaign, interval])
127129
128130 """ Get Indexes into Query """
129 - if query_type == 'banner':
130 - key_index = QD.get_banner_index(query_name)
131 - if query_type == 'LP':
132 - key_index = QD.get_landing_page_index(query_name)
 131+ key_index = QD.get_key_index(query_name)
133132
134133 metric_index = QD.get_metric_index(query_name, metric_name)
135134 time_index = QD.get_time_index(query_name)
@@ -181,7 +180,6 @@
182181 self._db_.rollback()
183182 sys.exit(0)
184183
185 -
186184
187185 """ Ensure that the last time in the list is the endtime less the interval """
188186 for key in times.keys():
@@ -200,7 +198,51 @@
201199 metrics[key] = metrics_new
202200
203201 return [metrics, times]
 202+
 203+"""
 204+
 205+
 206+"""
 207+class CampaignIntervalReportingLoader(IntervalReportingLoader):
204208
 209+ def __init__(self):
 210+ IntervalReportingLoader.__init__(self)
 211+
 212+ """
 213+ <DESCRIPTION>
 214+
 215+ INPUT:
 216+ start_time - start timestamp for reporting
 217+ end_time - end timestamp for reporting
 218+ interval - minutely interval at which to report metrics
 219+ query_type - query type: 'banner', 'campaign', 'LP'
 220+ metric_name - the metric to report
 221+ campaign - the campaign on which to select
 222+
 223+
 224+ RETURN:
 225+ metrics - dict containing metric measure for each time index for each donation pipeline handle (e.g. banner names)
 226+ times - dict containing time index for each donation pipeline handle (e.g. banner names)
 227+ """
 228+ def run_query(self, start_time, end_time, interval, query_type, metric_name, campaign):
 229+
 230+ query_type_1 = 'campaign'
 231+ query_type_2 = 'campaign_total'
 232+
 233+ """ Execute the standard interval reporting query """
 234+ metrics, times = IntervalReportingLoader.run_query(self, start_time, end_time, interval, query_type_1, metric_name, campaign)
 235+
 236+ """ Get the totals for campaign views and donations """
 237+ metrics_total, times_total = IntervalReportingLoader.run_query(self, start_time, end_time, interval, query_type_2, metric_name, campaign)
 238+
 239+ """ Combine the results for the campaign totals with (banner, landing page, campaign) """
 240+ for key in metrics_total.keys():
 241+ metrics[key] = metrics_total[key]
 242+ times[key] = times_total[key]
 243+
 244+
 245+ return [metrics, times]
 246+
205247
206248 class BannerLPReportingLoader(DataLoader):
207249

Status & tagging log