r91001 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91000‎ | r91001 | r91002 >
Date:21:15, 28 June 2011
Author:rfaulk
Status:deferred
Tags:
Comment:
Added ordering of column names for html table reporting
Handling of extracting data from dataloader when after query has already been run
Modified paths:
  • /trunk/fundraiser-statistics/fundraiser-scripts/classes/DataReporting.py (modified) (history)

Diff [purge]

Index: trunk/fundraiser-statistics/fundraiser-scripts/classes/DataReporting.py
@@ -16,25 +16,18 @@
1717 __date__ = "December 16th, 2010"
1818
1919
20 -import sys
21 -# sys.path.append('../')
 20+""" Import python base modules """
 21+import sys, matplotlib, datetime, MySQLdb, pylab, HTML, math
2222
23 -import matplotlib
24 -import datetime
25 -import MySQLdb
26 -import pylab
27 -# from matplotlib.lines import Line2D
28 -import HTML
29 -import math
30 -
 23+""" Import Analytics modules """
3124 import Fundraiser_Tools.classes.QueryData as QD
3225 import Fundraiser_Tools.classes.Helper as Hlp
3326 import Fundraiser_Tools.classes.TimestampProcessor as TP
3427 import Fundraiser_Tools.classes.DataLoader as DL
3528 import Fundraiser_Tools.classes.HypothesisTest as HT
 29+import Fundraiser_Tools.classes.FundraiserDataHandler as FDH
3630
3731
38 -# matplotlib.use('Agg')
3932
4033
4134
@@ -245,9 +238,11 @@
246239 for key in kwargs:
247240 if key == 'query_type': # Set custom data loaders
248241 if kwargs[key] == 'campaign':
249 - self._data_loader_ = DL.CampaignIntervalReportingLoader(kwargs[key])
 242+ self._data_loader_ = DL.CampaignIntervalReportingLoader()
250243 else:
251244 self._data_loader_ = DL.IntervalReportingLoader(kwargs[key])
 245+ elif key == 'was_run':
 246+ self._was_run_ = kwargs[key]
252247
253248 """ Call constructor of parent """
254249 DataReporting.__init__(self, **kwargs)
@@ -316,7 +311,7 @@
317312
318313 #line_types = ['b-o','g-o','r-o','c-o','m-o','k-o','y-o','b--d','g--d','r--d','c--d','m--d','k--d','y--d','b-.s','g-.s','r-.s','c-.s','m-.s','k-.s','y-.s']
319314 line_types = ['b-o','g-x','r-s','c-d','m-o','k-o','y-o','b--d','g--d','r--d','c--d','m--d','k--d','y--d','b-.s','g-.s','r-.s','c-.s','m-.s','k-.s','y-.s']
320 -
 315+
321316 count = 0
322317 for key in metrics.keys():
323318 if self._plot_type_ == 'step':
@@ -378,13 +373,17 @@
379374 print >> sys.stderr, 'No summary data for this reporting object.\n'
380375 return 0
381376
 377+ """ EXTRACT COLUMN NAMES AND ORDER THEM """
 378+
382379 data = self._data_loader_._summary_data_
383380 index = self._data_loader_._summary_data_.keys()[0]
384381 col_names = self._data_loader_._summary_data_[index].keys()
385382
386 - html = '<table border=\"1\" cellpadding=\"5\"><tr>'
 383+ col_names = FDH.order_column_keys(col_names)
387384
 385+ html = '<table border=\"1\" cellpadding=\"10\"><tr>'
388386
 387+
389388 """ Build headers """
390389 html = html + '<th>' + self._data_loader_._query_type_ + '</th>'
391390 for i in col_names:
@@ -396,8 +395,8 @@
397396 for item in data.keys():
398397 html = html + '<tr>'
399398 html = html + '<td>' + item + '</td>'
400 - for elem in data[item].keys():
401 - html = html + '<td>' + str(data[item][elem]) + '</td>'
 399+ for elem in col_names:
 400+ html = html + '<td>' + QD.get_metric_data_type(elem,data[item][elem]) + '</td>'
402401 html = html + '</tr>'
403402
404403 html = html + '</table>'
@@ -433,10 +432,10 @@
434433 for key in self._times_.keys():
435434 self._times_[key] = TP.normalize_timestamps(self._times_[key], False, 3)
436435 self._times_[key], self._counts_[key] = TP.normalize_intervals(self._times_[key], self._counts_[key], interval)
437 -
 436+
438437 """ If there are missing metrics add them as zeros """
439438 for label in labels:
440 -
 439+
441440 if not(label in self._times_.keys()):
442441 self._times_[label] = self._times_[self._times_.keys()[0]]
443442 self._counts_[label] = [0.0] * len(self._times_[label])
@@ -772,7 +771,7 @@
773772 test_call = "run('" + test_name + "', '" + query_name + "', '" + metric_name + "', '" + campaign + "', '" + \
774773 item_1 + "', '" + item_2 + "', '" + start_time + "', '" + end_time + "', " + str(interval) + ", " + str(num_samples) + ")"
775774 winner, percent_increase = self.print_metrics(fname, title, means_1, means_2, std_devs_1, std_devs_2, times_indices, labels, test_call)
776 -
 775+
777776 return [winner, percent_increase, confidence]
778777
779778

Status & tagging log