<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,5 +1,3 @@
-include BotParser
-
 class FilterController &lt; ApplicationController
   protect_from_forgery :only =&gt; [:create, :update, :destroy]
 
@@ -13,15 +11,27 @@ class FilterController &lt; ApplicationController
   def data
     respond_to do |format|
       format.js do
-        conditions = Hash.new
-        params[:filter].each { |k, v| conditions[k] = v if (!(k == 'page_type' || v == '')) }
-				conditions['timepoint'] = params[:dfilter][:single] if params[:dfilter][:single].to_s != ''
-        #if params[:dfilter][:start].to_s != '' &amp;&amp; params[:dfilter][:end].to_s != ''
-        #  conditions &lt;&lt; &quot; AND timepoint BETWEEN '&quot; + params[:dfilter][:start] + &quot;' AND '&quot; + params[:dfilter][:end] + &quot; 23:59:59'&quot;
-        #end
+        conditions = 'TRUE'
+        params[:filter].each { |k, v| conditions += &quot; AND #{k} = '#{v}'&quot; if (!(k == 'page_type' || v == '')) }
+        if params[:dfilter][:start] &amp;&amp; params[:dfilter][:end] &amp;&amp; params[:dfilter][:start].to_s != '' &amp;&amp; params[:dfilter][:end].to_s != ''
+          conditions &lt;&lt; &quot; AND timepoint BETWEEN '&quot; + params[:dfilter][:start] + &quot;' AND '&quot; + params[:dfilter][:end] + &quot; 23:59:59'&quot;
+        end
         data = retrieve_data(conditions)
         render :json =&gt; data.to_json, :layout =&gt; false
       end
     end
   end
+  def retrieve_data(conditions)
+    bots = Bot.find(:all)
+		shift = 100000000/bots.size
+
+    filtered_day_hits = []
+		dayhits = DayHit.find_by_sql &quot;SELECT SUM(count) AS count, EXTRACT(epoch FROM date(timepoint))*1000+(bot_id-1)*#{shift} AS site_id, bot_id, timepoint FROM (SELECT timepoint, bot_id, count, response FROM day_hits WHERE #{conditions}) foo GROUP BY response, timepoint, bot_id&quot;
+		dayhits.each { |dh| filtered_day_hits &lt;&lt; { :timestamp =&gt; dh.site_id, :count =&gt; dh.count, :bot_id =&gt; dh.bot_id } }
+
+    filtered_hits = []
+		dayhits = DayHit.find_by_sql &quot;SELECT * FROM (SELECT EXTRACT(epoch FROM date(dh.timepoint))*1000+(dh.bot_id-1)*#{shift} AS site_id, '&lt;tr&gt;&lt;td&gt;' || dh.url || '&lt;/td&gt;&lt;td&gt;' || hi.timepoint || '&lt;/td&gt;&lt;td&gt;' || dh.response || '&lt;/td&gt;&lt;td&gt;' || hi.ip || '&lt;/td&gt;&lt;/tr&gt;' AS url FROM hits hi JOIN (SELECT DISTINCT(id), url, bot_id, response, timepoint FROM day_hits WHERE #{conditions}) dh ON dh.id = hi.day_hit_id) foo GROUP BY site_id, url&quot;
+		dayhits.each { |dh| filtered_hits &lt;&lt; { :timestamp =&gt; dh.site_id, :html =&gt; dh.url } }
+    { :bots =&gt; bots, :hits =&gt; filtered_hits, :day_hits =&gt; filtered_day_hits }
+  end 
 end</diff>
      <filename>app/controllers/filter_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,8 +5,8 @@
 
 &lt;div id=&quot;pre_data&quot;&gt;
   &lt;div id=&quot;filters&quot;&gt;
-    &lt;p class=&quot;single&quot;&gt;&lt;label&gt;Single Date:&lt;/label&gt;&lt;input type=&quot;text&quot; id=&quot;datepicker_single&quot; /&gt;&lt;/p&gt;
-    &lt;p class=&quot;range&quot;&gt;&lt;label&gt;Date Range:&lt;/label&gt;&lt;input type=&quot;text&quot; id=&quot;datepicker_start&quot; /&gt; to &lt;input type=&quot;text&quot; id=&quot;datepicker_end&quot; /&gt;&lt;/p&gt;
+    &lt;p class=&quot;single&quot;&gt;&lt;img src=&quot;&quot; alt=&quot;-&gt;&quot; /&gt;&lt;label&gt;Single Date:&lt;/label&gt;&lt;input type=&quot;text&quot; id=&quot;datepicker_single&quot; /&gt;&lt;/p&gt;
+    &lt;p class=&quot;range&quot;&gt;&lt;img src=&quot;&quot; alt=&quot;-&gt;&quot; /&gt;&lt;label&gt;Date Range:&lt;/label&gt;&lt;input type=&quot;text&quot; id=&quot;datepicker_start&quot; /&gt; to &lt;input type=&quot;text&quot; id=&quot;datepicker_end&quot; /&gt;&lt;/p&gt;
     &lt;p&gt;&lt;label&gt;Bots:&lt;/label&gt;&lt;%= collection_select(:filter, :bot_id, @bots, :id, :name, {:include_blank =&gt; true}) %&gt;&lt;/p&gt;
     &lt;p&gt;&lt;label&gt;Sites:&lt;/label&gt;&lt;%= collection_select(:filter, :site, current_user.sites, :id, :name, {:include_blank =&gt; true}) %&gt;&lt;/p&gt;
     &lt;p&gt;&lt;label&gt;Responses:&lt;/label&gt;&lt;%= collection_select(:filter, :response, @responses, :response, :response, {:include_blank =&gt; true}) %&gt;&lt;/p&gt;</diff>
      <filename>app/views/filter/index.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -4,16 +4,10 @@ $(function() {
 
 var data, plot, previousPoint;
 var plot_data = [];
-var blah = {};
-blah['l2'] = {};
-blah['l3'] = {};
-blah['l4'] = {};
-blah['l2'].shift = 50000000;
-blah['l2'].lineWidth = 7;
-blah['l3'].shift = 33333333;
-blah['l3'].lineWidth = 5;
-blah['l4'].shift = 25000000;
-blah['l4'].lineWidth = 3;
+var thickness = {};
+thickness['l2'] = 7;
+thickness['l3'] = 5;
+thickness['l4'] = 3;
 
 var showTooltip = function(x, y, contents) {
   $('&lt;div id=&quot;tooltip&quot;&gt;' + contents + '&lt;/div&gt;').css( {
@@ -28,30 +22,14 @@ var showTooltip = function(x, y, contents) {
   }).appendTo(&quot;body&quot;).fadeIn(200);
 };
 
-var process_data = function(site) {
+var process_data = function() {
   var processed_data = {};
   $.each(data.bots, function(id, p) {
     processed_data['bot' + p.bot.id] = new Array;
   });
   var d = {};
   $.each(data.day_hits, function(id, p) {
-    if(site == p.site_id || !site) {
-      if(d[p.key]) {
-        d[p.key].count += p.count;
-      } else {
-        d[p.key] = {};
-        d[p.key].count = p.count;
-        d[p.key].timepoint = p.timepoint + (p.bot_id - 1) * blah['l' + data.bots.length].shift;
-        d[p.key].bot_id = p.bot_id;
-        d[p.key].site_id = p.site_id;
-        d[p.key].key = p.key;
-        d[p.key].url = p.url;
-        d[p.key].response = p.response;
-      }
-    }
-  });
-  $.each(d, function(id, p) {
-    processed_data['bot' + p.bot_id].push([p.timepoint, p.count, p.bot_id, p.site_id, p.key, p.url, p.response]);
+		processed_data['bot' + p.bot_id].push([p.timestamp, p.count]);
   });
   $.each(data.bots, function(id, p) {
     if(processed_data['bot' + p.bot.id].length &gt; 0) {
@@ -66,7 +44,7 @@ var plot_the_data = function() {
   plot = $.plot($('div#data'),
     plot_data,
     { points: { show: true,  radius: 2, fillColor: null },
-    bars: { show: true, lineWidth: blah['l' + data.bots.length].lineWidth },
+    bars: { show: true, lineWidth: thickness['l' + data.bots.length] },
     selection: { mode: &quot;xy&quot; },
     grid: { hoverable: true, clickable: true },
     xaxis: { mode: &quot;time&quot;, timeformat: &quot;%m/%d&quot; },
@@ -86,14 +64,12 @@ var plot_the_data = function() {
 var clicked = function (event, pos, item) {
 	if(item) {
   	var html = '&lt;table id=&quot;hit_data&quot;&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Url&lt;/th&gt;&lt;th&gt;Moment&lt;/th&gt;&lt;th&gt;Response&lt;/th&gt;&lt;th&gt;IP&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;';
-		var point = plot_data[item.seriesIndex].data[item.dataIndex];
   	$.each(data.hits, function(id, h) {
-   	 	if(h.key == point[4] &amp;&amp; (h.site_id == point[3] || $('#filter_site').val() == '')) {
-      	html += '&lt;tr&gt;&lt;td&gt;' + h.value.replace(/;;/g, '&lt;/td&gt;&lt;td&gt;') + '&lt;/td&gt;&lt;/tr&gt;';
+		  if(h.timestamp == item.datapoint[0]) {
+     		html += h.html;
     	}
   	});
   	html += '&lt;/tbody&gt;&lt;/table&gt;';
-  	plot_the_data();
   	$('div#shown_data').html(html);
   	$('table#hit_data').tablesorter();
 	}</diff>
      <filename>public/javascripts/bot_parser.js</filename>
    </modified>
    <modified>
      <diff>@@ -19,7 +19,7 @@ var run_filter = function() {
   if($('#datepicker_single').attr('disabled')) {
     args += '&amp;dfilter[start]=' + $('#datepicker_start').val() + '&amp;dfilter[end]=' + $('#datepicker_end').val();
   } else {
-    args += '&amp;dfilter[single]=' + $('#datepicker_single').val();
+    args += '&amp;filter[timepoint]=' + $('#datepicker_single').val();
   }
   $.ajax({
     type: 'POST',
@@ -29,7 +29,7 @@ var run_filter = function() {
     success: function(json) {
       plot_data = [];
       data = json;
-      process_data($('#filter_site').val());
+      process_data();
       plot_the_data();
     },
     error: function (XMLHttpRequest, textStatus, errorThrown) {</diff>
      <filename>public/javascripts/filter.js</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>lib/bot_parser.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>a555518d0737fe2239d31bdbbcf269a875446585</id>
    </parent>
  </parents>
  <author>
    <name>Steph Powell</name>
    <email>steph@endpoint.com</email>
  </author>
  <url>http://github.com/stephp/botpo/commit/925fae6d6d425e9cc68ff075699b05cc6433444b</url>
  <id>925fae6d6d425e9cc68ff075699b05cc6433444b</id>
  <committed-date>2009-10-20T11:19:19-07:00</committed-date>
  <authored-date>2009-10-20T11:19:19-07:00</authored-date>
  <message>Cleanup.</message>
  <tree>73352932b1e44e7b275a9ba92ed4f17025423e05</tree>
  <committer>
    <name>Steph Powell</name>
    <email>steph@endpoint.com</email>
  </committer>
</commit>
