Index: trunk/fundraiser-statistics/fundraiser-scripts/fundraiser_reporting.py |
— | — | @@ -1212,11 +1212,26 @@ |
1213 | 1213 | times = mh.AutoVivification() |
1214 | 1214 | times_norm = mh.AutoVivification() |
1215 | 1215 | |
| 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 | + |
1216 | 1231 | """ Load the SQL File & Format """ |
1217 | 1232 | filename = './sql/' + query_name + '.sql' |
1218 | 1233 | sql_stmnt = mh.read_sql(filename) |
1219 | 1234 | |
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]) |
1221 | 1236 | # print sql_stmnt |
1222 | 1237 | |
1223 | 1238 | """ Get Indexes into Query """ |
— | — | @@ -1224,17 +1239,6 @@ |
1225 | 1240 | metric_index = query_obj.get_metric_index(query_name, metric_name) |
1226 | 1241 | time_index = query_obj.get_time_index(query_name) |
1227 | 1242 | |
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 | | - |
1239 | 1243 | """ Compose the data for each separate donor pipeline artifact """ |
1240 | 1244 | try: |
1241 | 1245 | err_msg = sql_stmnt |
— | — | @@ -1279,15 +1283,14 @@ |
1280 | 1284 | self.db.rollback() |
1281 | 1285 | sys.exit("Database Interface Exception:\n" + err_msg) |
1282 | 1286 | |
1283 | | - |
| 1287 | + |
| 1288 | + |
1284 | 1289 | """ Ensure that the last time in the list is the endtime less the interval """ |
1285 | 1290 | |
1286 | 1291 | for key in times.keys(): |
1287 | 1292 | if final_time[key_name] != end_time_obj_str: |
1288 | 1293 | times[key].append(end_time_obj) |
1289 | 1294 | metrics[key].append(0.0) |
1290 | | - |
1291 | | - # print times |
1292 | 1295 | |
1293 | 1296 | self.close_db() |
1294 | 1297 | |
— | — | @@ -1308,6 +1311,7 @@ |
1309 | 1312 | |
1310 | 1313 | pylab.grid() |
1311 | 1314 | pylab.xlim(ranges[0], ranges[1]) |
| 1315 | + pylab.ylim(ranges[2], ranges[3]) |
1312 | 1316 | pylab.legend(metrics.keys(),loc=2) |
1313 | 1317 | |
1314 | 1318 | pylab.xlabel(xlabel) |
— | — | @@ -1351,8 +1355,8 @@ |
1352 | 1356 | title = campaign + ': ' + metric_full_name + ' -- ' + start_time + ' - ' + end_time |
1353 | 1357 | ylabel = metric_full_name |
1354 | 1358 | |
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 """ |
1357 | 1361 | for key in counts.keys(): |
1358 | 1362 | counts_new = list() |
1359 | 1363 | for i in range(len(counts[key])): |
— | — | @@ -1374,9 +1378,9 @@ |
1375 | 1379 | times_max = list_max |
1376 | 1380 | |
1377 | 1381 | ranges = list() |
1378 | | - ranges.append(0) |
| 1382 | + ranges.append(0.0) |
1379 | 1383 | ranges.append(times_max * 1.1) |
1380 | | - ranges.append(0) |
| 1384 | + ranges.append(0.0) |
1381 | 1385 | ranges.append(metrics_max * 1.1) |
1382 | 1386 | |
1383 | 1387 | |
Index: trunk/fundraiser-statistics/fundraiser-scripts/query_store.py |
— | — | @@ -133,14 +133,17 @@ |
134 | 134 | end_time = args[1] |
135 | 135 | campaign = args[2] |
136 | 136 | 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, \ |
138 | 140 | '%', '%', '%', '%', interval, interval, start_time, end_time, campaign) |
139 | | - |
| 141 | + |
140 | 142 | elif query_name == 'report_LP_metrics_minutely': |
141 | 143 | start_time = args[0] |
142 | 144 | end_time = args[1] |
143 | 145 | campaign = args[2] |
144 | 146 | interval = args[3] |
| 147 | + |
145 | 148 | sql_stmnt = sql_stmnt % ('%', '%', '%', '%', interval, interval, start_time, end_time, campaign, '%', '%', '%', '%', interval, interval, start_time, end_time, campaign) |
146 | 149 | |
147 | 150 | else: |