r78658 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r78657‎ | r78658 | r78659 >
Date:01:00, 21 December 2010
Author:rfaulk
Status:deferred
Tags:
Comment:
Added credit card paypal amounts and completion rates to reporting.
Modified paths:
  • /trunk/fundraiser-statistics/fundraiser-scripts/fundraiser_reporting.py (modified) (history)

Diff [purge]

Index: trunk/fundraiser-statistics/fundraiser-scripts/fundraiser_reporting.py
@@ -48,8 +48,8 @@
4949 def init_db(self):
5050 """ Establish connection """
5151 #db = MySQLdb.connect(host='db10.pmtpa.wmnet', user='rfaulk', db='faulkner')
52 - #self.db = MySQLdb.connect(host='127.0.0.1', user='rfaulk', db='faulkner', port=3307)
53 - self.db = MySQLdb.connect(host='storage3.pmtpa.wmnet', user='rfaulk', db='faulkner')
 52+ self.db = MySQLdb.connect(host='127.0.0.1', user='rfaulk', db='faulkner', port=3307)
 53+ #self.db = MySQLdb.connect(host='storage3.pmtpa.wmnet', user='rfaulk', db='faulkner')
5454
5555 """ Create cursor """
5656 self.cur = self.db.cursor()
@@ -315,34 +315,13 @@
316316
317317 labels = return_val[0] # curve labels
318318 counts = return_val[1] # curve data - lists
319 -
320 - if type == 'BAN_EM':
321 - indices = range(2,9)
322 - title = 'Total Amounts: ' + start_time + ' -- ' + end_time
323 - ylabel = 'Amount'
324 - elif type == 'CC_PP_completion':
325 - indices = [12,17]
326 - title = 'Credit Card & Paypal Completion Rates: ' + start_time + ' -- ' + end_time
327 - ylabel = 'Rate'
328 - elif type == 'CC_PP_amount':
329 - indices = [13,18]
330 - title = 'Credit Card & Paypal Total Amounts: ' + start_time + ' -- ' + end_time
331 - ylabel = 'Amount'
332 - else:
333 - sys.exit("Total Amounts: You must enter a valid report type.\n" )
334319
335 - # Exract relevant labels and values
336 - labels_temp = list()
337 - counts_temp = list()
 320+ r = self.get_query_fields(labels, counts, type, start_time, end_time)
 321+ labels = r[0]
 322+ counts = r[1]
 323+ title = r[2]
 324+ ylabel = r[3]
338325
339 - for i in range(len(labels)):
340 - if i in indices:
341 - labels_temp.append(labels[i])
342 - counts_temp.append(counts[i])
343 -
344 - labels = labels_temp
345 - counts = counts_temp
346 -
347326 xlabel = 'Time - Hours'
348327 subplot_index = 111
349328
@@ -385,9 +364,13 @@
386365 labels = return_val[0]
387366 counts = return_val[1]
388367
389 - title = 'Total Amounts: ' + start_time + ' -- ' + end_time
 368+ r = self.get_query_fields(labels, counts, 'BAN_EM', start_time, end_time)
 369+ labels = r[0]
 370+ counts = r[1]
 371+ title = r[2]
 372+ ylabel = r[3]
 373+
390374 xlabel = 'Time - Days'
391 - ylabel = 'Amount'
392375 subplot_index = 111
393376
394377 # Plot values
@@ -400,8 +383,34 @@
401384 self.gen_plot(time_range, counts, labels, title, xlabel, ylabel, ranges, subplot_index, query_name+descriptor)
402385
403386
 387+ def get_query_fields(self, labels, counts, type, start_time, end_time):
404388
 389+ if type == 'BAN_EM':
 390+ indices = range(2,9)
 391+ title = 'Total Amounts: ' + start_time + ' -- ' + end_time
 392+ ylabel = 'Amount'
 393+ elif type == 'CC_PP_completion':
 394+ indices = [12,17]
 395+ title = 'Credit Card & Paypal Completion Rates: ' + start_time + ' -- ' + end_time
 396+ ylabel = 'Rate'
 397+ elif type == 'CC_PP_amount':
 398+ indices = [13,18]
 399+ title = 'Credit Card & Paypal Total Amounts: ' + start_time + ' -- ' + end_time
 400+ ylabel = 'Amount'
 401+ else:
 402+ sys.exit("Total Amounts: You must enter a valid report type.\n" )
 403+
 404+ # Exract relevant labels and values
 405+ labels_temp = list()
 406+ counts_temp = list()
 407+
 408+ for i in range(len(labels)):
 409+ if i in indices:
 410+ labels_temp.append(labels[i])
 411+ counts_temp.append(counts[i])
405412
 413+ return [labels_temp, counts_temp, title, ylabel]
 414+
406415 """
407416
408417 CLASS :: ^BannerLPReporting^

Status & tagging log