r85107 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85106‎ | r85107 | r85108 >
Date:08:06, 1 April 2011
Author:rfaulk
Status:deferred
Tags:
Comment:
Modified the start time formatting for impressions.
Modified paths:
  • /trunk/fundraiser-statistics/fundraiser-scripts/fundraiser_reporting.py (modified) (history)
  • /trunk/fundraiser-statistics/fundraiser-scripts/query_store.py (modified) (history)

Diff [purge]

Index: trunk/fundraiser-statistics/fundraiser-scripts/fundraiser_reporting.py
@@ -1212,11 +1212,26 @@
12131213 times = mh.AutoVivification()
12141214 times_norm = mh.AutoVivification()
12151215
 1216+ """ Compose datetime objects to represent the first and last intervals """
 1217+ start_time_obj = self.timestamp_to_obj(start_time, 1)
 1218+ start_time_obj = start_time_obj.replace(minute=int(math.floor(start_time_obj.minute / interval) * interval))
 1219+ start_time_obj_str = self.timestamp_from_obj(start_time_obj, 1, 3)
 1220+
 1221+ end_time_obj = self.timestamp_to_obj(end_time, 1)
 1222+ # end_time_obj = end_time_obj + datetime.timedelta(seconds=-1)
 1223+ end_time_obj = end_time_obj.replace(minute=int(math.floor(end_time_obj.minute / interval) * interval))
 1224+ end_time_obj_str = self.timestamp_from_obj(end_time_obj, 1, 3)
 1225+
 1226+ """ The start time for the impression portion of the query should be one second less"""
 1227+
 1228+ imp_start_time_obj = start_time_obj + datetime.timedelta(seconds=-1)
 1229+ imp_start_time_obj_str = self.timestamp_from_obj(imp_start_time_obj, 1, 3)
 1230+
12161231 """ Load the SQL File & Format """
12171232 filename = './sql/' + query_name + '.sql'
12181233 sql_stmnt = mh.read_sql(filename)
12191234
1220 - sql_stmnt = query_obj.format_query(query_name, sql_stmnt, [start_time, end_time, campaign, interval])
 1235+ sql_stmnt = query_obj.format_query(query_name, sql_stmnt, [start_time, end_time, campaign, interval, imp_start_time_obj_str])
12211236 # print sql_stmnt
12221237
12231238 """ Get Indexes into Query """
@@ -1224,17 +1239,6 @@
12251240 metric_index = query_obj.get_metric_index(query_name, metric_name)
12261241 time_index = query_obj.get_time_index(query_name)
12271242
1228 - """ Compose datetime objects to represent the first and last intervals """
1229 - start_time_obj = self.timestamp_to_obj(start_time, 1)
1230 - start_time_obj = start_time_obj.replace(minute=int(math.floor(start_time_obj.minute / interval) * interval))
1231 - start_time_obj_str = self.timestamp_from_obj(start_time_obj, 1, 2)
1232 -
1233 - end_time_obj = self.timestamp_to_obj(end_time, 1)
1234 - end_time_obj = end_time_obj + datetime.timedelta(seconds=-1)
1235 - end_time_obj = end_time_obj.replace(minute=int(math.floor(end_time_obj.minute / interval) * interval))
1236 - end_time_obj_str = self.timestamp_from_obj(end_time_obj, 1, 2)
1237 -
1238 -
12391243 """ Compose the data for each separate donor pipeline artifact """
12401244 try:
12411245 err_msg = sql_stmnt
@@ -1279,15 +1283,14 @@
12801284 self.db.rollback()
12811285 sys.exit("Database Interface Exception:\n" + err_msg)
12821286
1283 -
 1287+
 1288+
12841289 """ Ensure that the last time in the list is the endtime less the interval """
12851290
12861291 for key in times.keys():
12871292 if final_time[key_name] != end_time_obj_str:
12881293 times[key].append(end_time_obj)
12891294 metrics[key].append(0.0)
1290 -
1291 - # print times
12921295
12931296 self.close_db()
12941297
@@ -1308,6 +1311,7 @@
13091312
13101313 pylab.grid()
13111314 pylab.xlim(ranges[0], ranges[1])
 1315+ pylab.ylim(ranges[2], ranges[3])
13121316 pylab.legend(metrics.keys(),loc=2)
13131317
13141318 pylab.xlabel(xlabel)
@@ -1351,8 +1355,8 @@
13521356 title = campaign + ': ' + metric_full_name + ' -- ' + start_time + ' - ' + end_time
13531357 ylabel = metric_full_name
13541358
1355 - # Convert counts to float (from Decimal) to prevent exception when bar plotting
1356 - # Bbox::update_numerix_xy expected numerix array
 1359+ """ Convert counts to float (from Decimal) to prevent exception when bar plotting
 1360+ Bbox::update_numerix_xy expected numerix array """
13571361 for key in counts.keys():
13581362 counts_new = list()
13591363 for i in range(len(counts[key])):
@@ -1374,9 +1378,9 @@
13751379 times_max = list_max
13761380
13771381 ranges = list()
1378 - ranges.append(0)
 1382+ ranges.append(0.0)
13791383 ranges.append(times_max * 1.1)
1380 - ranges.append(0)
 1384+ ranges.append(0.0)
13811385 ranges.append(metrics_max * 1.1)
13821386
13831387
Index: trunk/fundraiser-statistics/fundraiser-scripts/query_store.py
@@ -133,14 +133,17 @@
134134 end_time = args[1]
135135 campaign = args[2]
136136 interval = args[3]
137 - sql_stmnt = sql_stmnt % ('%', '%', '%', '%', interval, interval, start_time, end_time, '%', '%', '%', '%', interval, interval, start_time, end_time, campaign, \
 137+ imp_start_time = args[4]
 138+
 139+ sql_stmnt = sql_stmnt % ('%', '%', '%', '%', interval, interval, imp_start_time, end_time, '%', '%', '%', '%', interval, interval, start_time, end_time, campaign, \
138140 '%', '%', '%', '%', interval, interval, start_time, end_time, campaign)
139 -
 141+
140142 elif query_name == 'report_LP_metrics_minutely':
141143 start_time = args[0]
142144 end_time = args[1]
143145 campaign = args[2]
144146 interval = args[3]
 147+
145148 sql_stmnt = sql_stmnt % ('%', '%', '%', '%', interval, interval, start_time, end_time, campaign, '%', '%', '%', '%', interval, interval, start_time, end_time, campaign)
146149
147150 else:

Status & tagging log