<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>public/images/next.png</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -3,17 +3,17 @@ class FilterController &lt; ApplicationController
 
   def index
     @bots = Bot.find(:all)
-    @responses = DayHit.find(:all, :select =&gt; 'DISTINCT response')
-    @urls = DayHit.find(:all, :select =&gt; 'DISTINCT url')
-    @page_types = PageType.find(:all) 
+		@responses = [200, 301, 302, 304, 400, 404, 409, 500, 502, 503]
+		#@urls = DayHit.find_by_sql &quot;SELECT DISTINCT url FROM day_hits LIMIT 10&quot;
+    #@page_types = PageType.find(:all) 
   end
 
   def data
     respond_to do |format|
       format.js do
         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 != ''
+        params[:filter].each { |k, v| conditions += &quot; AND #{k} = '#{v}'&quot; if (!(k == 'page_type' || v == '' || v == 'undefined')) }
+        if params[:dfilter] &amp;&amp; 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)
@@ -26,12 +26,18 @@ class FilterController &lt; ApplicationController
 		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 } }
+		max = 0
+		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 FROM day_hits WHERE #{conditions}) foo GROUP BY timepoint, bot_id&quot;
+		dayhits.each do |dh|
+		  filtered_day_hits &lt;&lt; { :timestamp =&gt; dh.site_id, :count =&gt; dh.count, :bot_id =&gt; dh.bot_id }
+			max = dh.count if dh.count &gt; max
+		end
 
     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 } }
+		if max &lt; 1000
+			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 } }
+		end
     { :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,16 +5,27 @@
 
 &lt;div id=&quot;pre_data&quot;&gt;
   &lt;div id=&quot;filters&quot;&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 class=&quot;all&quot;&gt;&lt;img src=&quot;/images/next.png&quot; alt=&quot;-&gt;&quot; /&gt;&lt;label&gt;All Dates&lt;/label&gt;&lt;/p&gt;
+    &lt;p class=&quot;single&quot;&gt;&lt;img src=&quot;/images/next.png&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;/images/next.png&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;
+    &lt;p&gt;&lt;label&gt;Sites:&lt;/label&gt;&lt;%= collection_select(:filter, :site, current_user.sites, :id, :name, {:include_blank =&gt; false}) %&gt;&lt;/p&gt;
+    &lt;p&gt;&lt;label&gt;Responses:&lt;/label&gt;
+			&lt;select id=&quot;filter_response&quot; name=&quot;filter[response]&quot;&gt;
+			&lt;option value=&quot;&quot;&gt;All&lt;/option&gt;
+			&lt;% @responses.each do |r| -%&gt;&lt;option value=&quot;&lt;%= r.to_s %&gt;&quot;&gt;&lt;%= r.to_s %&gt;&lt;/option&gt;&lt;% end -%&gt;
+			&lt;/select&gt;
+		&lt;/p&gt;
+		&lt;% if @urls -%&gt;
     &lt;p&gt;&lt;label&gt;URLS:&lt;/label&gt;&lt;%= collection_select(:filter, :url, @urls, :url, :url, {:include_blank =&gt; true}) %&gt;&lt;/p&gt;
-    &lt;!--&lt;p&gt;&lt;label&gt;Page Types:&lt;/label&gt;&lt;input id=&quot;filter_page_type&quot; value=&quot;&quot; /&gt;&lt;/p&gt;--&gt;
+		&lt;% end -%&gt;
+		&lt;% if @page_types -%&gt;
+    &lt;p&gt;&lt;label&gt;Page Types:&lt;/label&gt;&lt;input id=&quot;filter_page_type&quot; value=&quot;&quot; /&gt;&lt;/p&gt;
+		&lt;% end -%&gt;
     &lt;a href=&quot;#&quot; class=&quot;run_filter&quot;&gt;Run&lt;/a&gt;
   &lt;/div&gt;
 &lt;/div&gt;
 
+&lt;div id=&quot;legend&quot;&gt;&lt;/div&gt;
 &lt;div id=&quot;data&quot;&gt;&lt;/div&gt;
 &lt;div id=&quot;shown_data&quot;&gt;&lt;/div&gt;</diff>
      <filename>app/views/filter/index.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -11,58 +11,13 @@ RAILS_GEM_VERSION = '2.1.0' unless defined? RAILS_GEM_VERSION
 require File.join(File.dirname(__FILE__), 'boot')
 
 Rails::Initializer.run do |config|
-  # Settings in config/environments/* take precedence over those specified here.
-  # Application configuration should go into files in config/initializers
-  # -- all .rb files in that directory are automatically loaded.
-  # See Rails::Configuration for more options.
-
-  # Skip frameworks you're not going to use. To use Rails without a database
-  # you must remove the Active Record framework.
-  # config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
-
-  # Specify gems that this application depends on. 
-  # They can then be installed with &quot;rake gems:install&quot; on new installations.
+  config.log_level = :error
   config.gem 'resource_controller'
   config.gem 'paperclip'
-
-  # Only load the plugins named here, in the order given. By default, all plugins 
-  # in vendor/plugins are loaded in alphabetical order.
-  # :all can be used as a placeholder for all plugins not explicitly named
-  # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
-
-  # Add additional load paths for your own custom dirs
-  # config.load_paths += %W( #{RAILS_ROOT}/extras )
-
-  # Force all environments to use the same logger level
-  # (by default production uses :info, the others :debug)
-  #config.log_level = :error
-
-  # Make Time.zone default to the specified zone, and make Active Record store time values
-  # in the database in UTC, and return them converted to the specified local zone.
-  # Run &quot;rake -D time&quot; for a list of tasks for finding time zone names. Uncomment to use default local time.
   config.time_zone = 'UTC'
-
-  # Your secret key for verifying cookie session data integrity.
-  # If you change this key, all old sessions will become invalid!
-  # Make sure the secret is at least 30 characters and all random, 
-  # no regular words or you'll be exposed to dictionary attacks.
   config.action_controller.session = {
     :session_key =&gt; '_botpo_session',
     :secret      =&gt; 'a5c350273c7c06fbefe00db45de1fd5967f8c2260e9cdf7814f819f58d61df966a1293300ff57aa15eff22b3acd8b77d8c86130a364d74d6907c2991994321aa'
   }
-
-  # Use the database for sessions instead of the cookie-based default,
-  # which shouldn't be used to store highly confidential information
-  # (create the session table with &quot;rake db:sessions:create&quot;)
-  # config.action_controller.session_store = :active_record_store
-
-  # Use SQL instead of Active Record's schema dumper when creating the test database.
-  # This is necessary if your schema can't be completely dumped by the schema dumper,
-  # like if you have constraints or database-specific column types
-  # config.active_record.schema_format = :sql
-
-  # Activate observers that should always be running
-  # config.active_record.observers = :cacher, :garbage_collector
-
   config.active_record.observers = :user_observer
 end</diff>
      <filename>config/environment.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,10 +4,6 @@ $(function() {
 
 var data, plot, previousPoint;
 var plot_data = [];
-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( {
@@ -23,11 +19,11 @@ var showTooltip = function(x, y, contents) {
 };
 
 var process_data = function() {
+	//STEPH TODO cleanup to optimize
   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) {
 		processed_data['bot' + p.bot_id].push([p.timestamp, p.count]);
   });
@@ -40,21 +36,29 @@ var process_data = function() {
 };
 
 var plot_the_data = function() {
+	plot_data = [];
+	process_data();
   $('div#data').unbind('plothover').unbind('plotclick').css('height', '400px');
   plot = $.plot($('div#data'),
     plot_data,
     { points: { show: true,  radius: 2, fillColor: null },
-    bars: { show: true, lineWidth: thickness['l' + data.bots.length] },
+    bars: { show: true, lineWidth: 2 },
     selection: { mode: &quot;xy&quot; },
     grid: { hoverable: true, clickable: true },
-    xaxis: { mode: &quot;time&quot;, timeformat: &quot;%m/%d&quot; },
-    yaxis: { min: 0, ticks: 10 },
+    xaxis: { mode: &quot;time&quot;, timeformat: &quot;%m/%d&quot;, autoscaleMargin: 0.05 },
+    yaxis: { min: 0, ticks: 10, autoscaleMargin: 0.1 },
+		legend: { container: $('div#legend') },
     shadowSize: 0
   });
 	if(plot_data.length &gt; 0) {
-  	$('div#data')
-			.bind('plothover', function(event, pos, item) { hover(event, pos, item) })
-    	.bind('plotclick', function(event, pos, item) { clicked(event, pos, item) });
+		if(data.hits.length &gt; 0) {
+  		$('div#data')
+				.bind('plothover', function(event, pos, item) { hover(event, pos, item) })
+				.bind('plotclick', function(event, pos, item) { clicked(event, pos, item) });
+				$('div#legend').append($(document.createElement('p')).html('Data is clickable'));
+		} else {
+		 	$('div#data').bind('plothover', function(event, pos, item) { hover(event, pos, item) });
+		}
 	} else {
 		$('div#data').html('there is no data.');
 	}</diff>
      <filename>public/javascripts/bot_parser.js</filename>
    </modified>
    <modified>
      <diff>@@ -7,18 +7,22 @@ $(function() {
   $('p.range img').click(function() { 
     $('p.single input').attr('disabled', true); $('p.range input').removeAttr('disabled');
   });
+	$('p.all img').click(function() {
+    $('p.range input').attr('disabled', true); 
+    $('p.single input').attr('disabled', true);
+	});
   $('a.run_filter').click(function() { $('div#data').html('&lt;img src=&quot;/images/ajax_loader.gif&quot; /&gt;'); run_filter(); });
 });
 
 var run_filter = function() {
   var args = 'filter[bot_id]=' + $('#filter_bot_id').val() +
     '&amp;filter[response]=' + $('#filter_response').val() +
-    '&amp;filter[url]=' + $('#filter_url').val() +
-    '&amp;filter[page_type]=' + $('#filter_page_type').val() +
+    //'&amp;filter[url]=' + $('#filter_url').val() +
+    //'&amp;filter[page_type]=' + $('#filter_page_type').val() +
     '&amp;filter[site_id]=' + $('#filter_site').val();
-  if($('#datepicker_single').attr('disabled')) {
+  if(!$('#datepicker_start').attr('disabled')) {
     args += '&amp;dfilter[start]=' + $('#datepicker_start').val() + '&amp;dfilter[end]=' + $('#datepicker_end').val();
-  } else {
+	} else if(!$('#datepicker_single').attr('disabled')) {
     args += '&amp;filter[timepoint]=' + $('#datepicker_single').val();
   }
   $.ajax({
@@ -27,13 +31,11 @@ var run_filter = function() {
     dataType: 'json',
     data: args,
     success: function(json) {
-      plot_data = [];
       data = json;
-      process_data();
       plot_the_data();
     },
     error: function (XMLHttpRequest, textStatus, errorThrown) {
-      alert('error');
+      alert('fail');
     }
   });
 };</diff>
      <filename>public/javascripts/filter.js</filename>
    </modified>
    <modified>
      <diff>@@ -7,7 +7,9 @@ h2 { font-size: 14px; }
 p { font-size: 12px; }
 
 div#filters { background-color: #b5bd9a; font-size: 11px; padding: 10px; }
-  div#filters img { float: left; }
+  div#filters img { float: left; position: relative; top: 4px; margin-right: 2px; }
+	div#filters p { height: 20px; }
+	div#filters img:hover { cursor: pointer; }
   div#filters input { font-size: 11px; }
   div#filters p { margin: 2px 0px; padding: 0px; clear: both; }
   div#filters p label { float: left; width: 100px; position: relative; top: 4px; }
@@ -17,7 +19,8 @@ div#ui-datepicker-div { background-color: #FFF; z-index: 30; font-size: 11px; }
   div#ui-datepicker-div a { text-decoration: none; }
 
 div#pre_data { margin-left: 10px; padding: 10px 0; position: relative; }
-div#data { width: 868px; margin: 0px auto; }
+div#legend { display: inline; }
+div#data { width: 800px; margin: 0px auto; }
 div#shown_data { margin: 10px 0px; }
 div.clear { clear: both; }
 </diff>
      <filename>public/stylesheets/bot_parser.css</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>8fe51a7e15d6d0783a94ae4c98a6c7fbabed4680</id>
    </parent>
  </parents>
  <author>
    <name>Steph Powell</name>
    <email>steph@endpoint.com</email>
  </author>
  <url>http://github.com/stephp/botpo/commit/9ce06b474d0390f67c228e59d89dd65d324efc54</url>
  <id>9ce06b474d0390f67c228e59d89dd65d324efc54</id>
  <committed-date>2009-10-20T13:28:04-07:00</committed-date>
  <authored-date>2009-10-20T13:28:04-07:00</authored-date>
  <message>Scalability work for client use.</message>
  <tree>06524f8a9334248d5c81f4269edd8c201034538d</tree>
  <committer>
    <name>Steph Powell</name>
    <email>steph@endpoint.com</email>
  </committer>
</commit>
