Index: trunk/fundraiser-statistics/fundraiser-scripts/fundraiser_reporting.py |
— | — | @@ -48,8 +48,8 @@ |
49 | 49 | def init_db(self): |
50 | 50 | """ Establish connection """ |
51 | 51 | #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') |
54 | 54 | |
55 | 55 | """ Create cursor """ |
56 | 56 | self.cur = self.db.cursor() |
— | — | @@ -315,34 +315,13 @@ |
316 | 316 | |
317 | 317 | labels = return_val[0] # curve labels |
318 | 318 | 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" ) |
334 | 319 | |
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] |
338 | 325 | |
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 | | - |
347 | 326 | xlabel = 'Time - Hours' |
348 | 327 | subplot_index = 111 |
349 | 328 | |
— | — | @@ -385,9 +364,13 @@ |
386 | 365 | labels = return_val[0] |
387 | 366 | counts = return_val[1] |
388 | 367 | |
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 | + |
390 | 374 | xlabel = 'Time - Days' |
391 | | - ylabel = 'Amount' |
392 | 375 | subplot_index = 111 |
393 | 376 | |
394 | 377 | # Plot values |
— | — | @@ -400,8 +383,34 @@ |
401 | 384 | self.gen_plot(time_range, counts, labels, title, xlabel, ylabel, ranges, subplot_index, query_name+descriptor) |
402 | 385 | |
403 | 386 | |
| 387 | + def get_query_fields(self, labels, counts, type, start_time, end_time): |
404 | 388 | |
| 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]) |
405 | 412 | |
| 413 | + return [labels_temp, counts_temp, title, ylabel] |
| 414 | + |
406 | 415 | """ |
407 | 416 | |
408 | 417 | CLASS :: ^BannerLPReporting^ |