<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>app/models/date_range.rb</filename>
    </added>
    <added>
      <filename>app/models/report.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -3,6 +3,7 @@ class Dashboard &lt; Application
   before :authenticate
   
   def index
+    @days = Report.days_from_range(Date.today - 30, Date.today)
     render
   end
   </diff>
      <filename>app/controllers/dashboard.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,28 @@
 module Merb
     module DashboardHelper
-
+      def google_bar_graph(collection, x_method, y_method, options = {})
+        options[:size] ||= &quot;580x200&quot;
+        options[:color] ||= &quot;c6d9fd&quot;
+        
+        max = collection.max{ |a,b| a.send(y_method) &lt;=&gt; b.send(y_method) }.send(y_method)
+        labels = []
+        collection.each do |item|
+          labels &lt;&lt; item.send(x_method)
+        end
+        
+        query = &quot;http://chart.apis.google.com/chart?cht=bvs&amp;chs=#{options[:size]}&amp;chco=#{options[:color]}&quot;
+        query &lt;&lt; &quot;&amp;chd=t:&quot; + collection.collect{|d| d.send(y_method) }.join(&quot;,&quot;)
+        query &lt;&lt; &quot;&amp;chds=0,#{max}&quot;
+        query &lt;&lt; &quot;&amp;chxt=x,y&quot;
+        query &lt;&lt; &quot;&amp;chxl=0:|#{labels.join('|')}|1:|0|#{number_with_delimiter max/4}|#{number_with_delimiter max*2/4}|#{number_with_delimiter max*3/4}|#{number_with_delimiter max}&quot;
+        query &lt;&lt; &quot;&amp;chg=&quot; + [5000, 25, 1, 3].join(',')
+        '&lt;img src=&quot;' + query + '&quot; alt=&quot;Graph&quot; /&gt;'
+      end
+      
+      def ctr(clicks, impressions)
+        num = clicks.to_f/impressions.to_f*100
+        num = 0 if num.nan?
+        number_to_percentage(num, :precision =&gt; 2)
+      end
     end
 end
\ No newline at end of file</diff>
      <filename>app/helpers/dashboard_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -28,5 +28,74 @@ module Merb
       &quot;&lt;form action=\&quot;#{url}\&quot; method=\&quot;post\&quot; class=\&quot;destroy\&quot;&gt;&lt;button type=\&quot;submit\&quot; class=\&quot;destroy\&quot;&gt;#{text}&lt;/button&gt;&lt;/form&gt;&quot;
     end
     
+    # Formats a +number+ with grouped thousands using +delimiter+ (e.g., 12,324). You
+    # can customize the format using optional &lt;em&gt;delimiter&lt;/em&gt; and &lt;em&gt;separator&lt;/em&gt; parameters.
+    #
+    # ==== Options
+    # * &lt;tt&gt;delimiter&lt;/tt&gt;  - Sets the thousands delimiter (defaults to &quot;,&quot;).
+    # * &lt;tt&gt;separator&lt;/tt&gt;  - Sets the separator between the units (defaults to &quot;.&quot;).
+    #
+    # ==== Examples
+    #  number_with_delimiter(12345678)       # =&gt; 12,345,678
+    #  number_with_delimiter(12345678.05)    # =&gt; 12,345,678.05
+    #  number_with_delimiter(12345678, &quot;.&quot;)  # =&gt; 12.345.678
+    #
+    #  number_with_delimiter(98765432.98, &quot; &quot;, &quot;,&quot;)
+    #  # =&gt; 98 765 432,98
+    def number_with_delimiter(number, delimiter=&quot;,&quot;, separator=&quot;.&quot;)
+      begin
+        parts = number.to_s.split('.')
+        parts[0].gsub!(/(\d)(?=(\d\d\d)+(?!\d))/, &quot;\\1#{delimiter}&quot;)
+        parts.join separator
+      rescue
+        number
+      end
+    end
+    
+    # Formats a +number+ as a percentage string (e.g., 65%). You can customize the
+    # format in the +options+ hash.
+    #
+    # ==== Options
+    # * &lt;tt&gt;:precision&lt;/tt&gt;  - Sets the level of precision (defaults to 3).
+    # * &lt;tt&gt;:separator&lt;/tt&gt;  - Sets the separator between the units (defaults to &quot;.&quot;).
+    #
+    # ==== Examples
+    #  number_to_percentage(100)                         # =&gt; 100.000%
+    #  number_to_percentage(100, :precision =&gt; 0)        # =&gt; 100%
+    #
+    #  number_to_percentage(302.24398923423, :precision =&gt; 5)
+    #  # =&gt; 302.24399%
+    def number_to_percentage(number, options = {})
+      options   = options.stringify_keys
+      precision = options[&quot;precision&quot;] || 3
+      separator = options[&quot;separator&quot;] || &quot;.&quot;
+
+      begin
+        number = number_with_precision(number, precision)
+        parts = number.split('.')
+        if parts.at(1).nil?
+          parts[0] + &quot;%&quot;
+        else
+          parts[0] + separator + parts[1].to_s + &quot;%&quot;
+        end
+      rescue
+        number
+      end
+    end
+    
+    # Formats a +number+ with the specified level of +precision+ (e.g., 112.32 has a precision of 2). The default
+    # level of precision is 3.
+    #
+    # ==== Examples
+    #  number_with_precision(111.2345)     # =&gt; 111.235
+    #  number_with_precision(111.2345, 2)  # =&gt; 111.23
+    #  number_with_precision(13, 5)        # =&gt; 13.00000
+    #  number_with_precision(389.32314, 0) # =&gt; 389
+    def number_with_precision(number, precision=3)
+      &quot;%01.#{precision}f&quot; % ((Float(number) * (10 ** precision)).round.to_f / 10 ** precision)
+    rescue
+      number
+    end
+    
   end
 end</diff>
      <filename>app/helpers/global_helpers.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1 +1,20 @@
-You're in index of the Dashboard
\ No newline at end of file
+&lt;h1&gt;Overview&lt;/h1&gt;
+
+&lt;h3&gt;Impressions in the past 30 days&lt;/h3&gt;
+&lt;p&gt;&lt;%= google_bar_graph(@days, :short_date, :impressions) %&gt;&lt;/p&gt;
+&lt;table&gt;
+  &lt;tr&gt;
+    &lt;th&gt;Date&lt;/th&gt;
+    &lt;th&gt;Impressions&lt;/th&gt;
+    &lt;th&gt;Clicks&lt;/th&gt;
+    &lt;th&gt;CTR&lt;/th&gt;
+  &lt;/tr&gt;
+  &lt;% for day in @days %&gt;
+  &lt;tr&gt;
+    &lt;td&gt;&lt;%= day.date.to_formatted_s(:general) %&gt;&lt;/td&gt;
+    &lt;td&gt;&lt;%= number_with_delimiter day.impressions %&gt;&lt;/td&gt;
+    &lt;td&gt;&lt;%= number_with_delimiter day.clicks %&gt;&lt;/td&gt;
+    &lt;td&gt;&lt;%= ctr(day.clicks, day.impressions) %&gt;&lt;/td&gt;
+  &lt;/tr&gt;
+  &lt;% end %&gt;
+&lt;/table&gt;
\ No newline at end of file</diff>
      <filename>app/views/dashboard/index.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -31,5 +31,5 @@ Merb::Router.prepare do |r|
   r.default_routes
   
   # Change this for your home page to be available at /
-  # r.match('/').to(:controller =&gt; 'whatever', :action =&gt;'index')
+  r.match('/').to(:controller =&gt; 'dashboard', :action =&gt;'index')
 end
\ No newline at end of file</diff>
      <filename>config/router.rb</filename>
    </modified>
    <modified>
      <diff>@@ -60,6 +60,17 @@ h2 em{
   color:#444;
 }
 
+h3{
+  font-size:14px;
+}
+
+h4{
+  font-size:12px;
+  font-weight:normal;
+  color:#666;
+  text-transform:uppercase;
+}
+
 a{
   color:#0077aa;
   text-decoration:none;
@@ -359,4 +370,30 @@ ul.full-width-spots li{
 }
 html&gt;body*#wrap .spots button.destroy{
   top:10px;
+}
+
+/*------------------------------------------------------------------------------------
+  Tables
+------------------------------------------------------------------------------------*/
+
+table{
+  width:100%;
+  border-spacing:0;
+  border-collapse:collapse;
+  border:1px solid #eee;
+  border-right:none;
+  border-bottom:none;
+}
+
+table th, table td{
+  padding:2px 5px;
+  text-align:left;
+  border:1px solid #eee;
+  border-top:none;
+  border-left:none;
+}
+
+table th{
+  text-transform:uppercase;
+  border-bottom:2px solid #eee;
 }
\ No newline at end of file</diff>
      <filename>public/stylesheets/master.css</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>45bab61ace1174c37cbfeea8c44c83cb0f45fcde</id>
    </parent>
  </parents>
  <author>
    <name>Kyle Neath</name>
    <email>kneath@gmail.com</email>
  </author>
  <url>http://github.com/kneath/greed/commit/5f97998a36ef6d4af5a6b18ed73e976b29a17a99</url>
  <id>5f97998a36ef6d4af5a6b18ed73e976b29a17a99</id>
  <committed-date>2008-05-11T22:18:10-07:00</committed-date>
  <authored-date>2008-05-11T22:18:10-07:00</authored-date>
  <message>Basic reporting on the Dashboard</message>
  <tree>43b24e6fb938e876d6c3a4c7128fce8398df6f44</tree>
  <committer>
    <name>Kyle Neath</name>
    <email>kneath@gmail.com</email>
  </committer>
</commit>
