public
Description: client-side performance measurement gem and plugin for rails
Homepage: http://austinentrepreneur.wordpress.com
Clone URL: git://github.com/efalcao/clientperf.git
h()'d stuff to comply with SafeERB. Added migrations to tables
efalcao (author)
Sun Jun 29 15:53:23 -0700 2008
commit  c538352522e44a39803ef229823b20ec800de16e
tree    246ad01c1c697a4dd062bc367ac6595688099034
parent  154292e9644cb7a7ecab29fa9d6d973eebc2c2d0
...
1
 
2
3
4
...
1
2
3
4
5
0
@@ -1,4 +1,5 @@
0
 = History
0
+* v0.1.6. Good with SafeERB now. Added indexes to the clientperf tables.
0
 * v0.1.3. Another timezone fix...
0
 * v0.1.2. Use ActiveRecord::Base.default_timezone when trying to format dateparts, thanks Mike Perham
0
 * v0.1.1. Fixed error when there is no data at all, thanks Mike Perham
...
27
28
29
30
 
31
32
33
...
27
28
29
 
30
31
32
33
0
@@ -27,7 +27,7 @@ module Clientperf
0
     end
0
     
0
     def version
0
- "0.1.5"
0
+ "0.1.6"
0
     end
0
     
0
     private
...
1
2
3
 
 
 
 
 
 
4
5
6
7
8
9
 
10
11
12
...
1
 
 
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
0
@@ -1,12 +1,17 @@
0
 module ClientperfHelper
0
- def chart(data)
0
- "http://chart.apis.google.com/chart?cht=ls&chs=300x100&chm=B,e6f2fa,0,0,0|R,000000,0,0.998,1.0&chco=0f7fcf&chxt=r&chd=s:#{chart_data(data)}"
0
+ def chart_for(data)
0
+ if encoded = chart_data(data)
0
+ image_tag("http://chart.apis.google.com/chart?cht=ls&chs=300x100&chm=B,e6f2fa,0,0,0|R,000000,0,0.998,1.0&chco=0f7fcf&chxt=r&chd=s:#{encoded}")
0
+ else
0
+ content_tag('p', "no data for this chart")
0
+ end
0
   end
0
   
0
   private
0
   
0
   def chart_data(args)
0
     data, max = args
0
+ return nil if max == 0 || data.size == 0
0
     max += max * 0.1
0
     encode = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
0
 
...
1
2
 
3
4
5
...
20
21
22
 
 
 
 
 
 
 
 
 
 
 
 
23
24
25
...
1
 
2
3
4
5
...
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
0
@@ -1,5 +1,5 @@
0
 class ClientperfMigrations
0
- MIGRATION_NAMES = %w(add_clientperf_tables)
0
+ MIGRATION_NAMES = %w(add_clientperf_tables add_clientperf_indexes)
0
   MIGRATION_CONTENTS = {
0
     :add_clientperf_tables => %(
0
 class AddClientperfTables < ActiveRecord::Migration
0
@@ -20,6 +20,18 @@ class AddClientperfTables < ActiveRecord::Migration
0
     drop_table :clientperf_uris
0
     drop_table :clientperf_results
0
   end
0
+end),
0
+ :add_clientperf_indexes => %(
0
+class AddClientperfIndexes < ActiveRecord::Migration
0
+ def self.up
0
+ add_index :clientperf_uris, :uri
0
+ add_index :clientperf_results, :clientperf_uri_id
0
+ end
0
+
0
+ def self.down
0
+ remove_index :clientperf_uris, :uri
0
+ remove_index :clientperf_results, :clientperf_uri_id
0
+ end
0
 end)
0
   }
0
   
...
5
6
7
8
 
9
10
11
...
17
18
19
20
 
21
22
23
24
 
25
26
27
...
5
6
7
 
8
9
10
11
...
17
18
19
 
20
21
22
23
 
24
25
26
27
0
@@ -5,7 +5,7 @@
0
       <% @uris.each do |uri| %>
0
       <tr>
0
         <td class="vital-stats">[ <%= number_with_precision(uri.clientperf_results.average(:milliseconds) / 1000.to_f, 2) %>s | <%= uri.clientperf_results.count %> ]</td>
0
- <td><%= link_to uri.uri, "/clientperf/#{uri.id}" %></td>
0
+ <td><%= link_to h(uri.uri), "/clientperf/#{uri.id}" %></td>
0
       </tr>
0
       <% end %>
0
     </table>
0
@@ -17,11 +17,11 @@
0
     <% if @uris.size > 0 %>
0
     <div class="chart">
0
       <h4>24 hour</h4>
0
- <img src="<%= chart(ClientperfResult.last_24_hours) %>" />
0
+ <%= chart_for(ClientperfResult.last_24_hours) %>
0
     </div>
0
     <div class="chart">
0
       <h4>30 day</h4>
0
- <img src="<%= chart(ClientperfResult.last_30_days)%>" />
0
+ <%= chart_for(ClientperfResult.last_30_days) %>
0
     </div>
0
     <% else %>
0
       <p>no data yet.</p>
...
3
4
5
6
 
7
8
9
10
 
11
12
13
...
3
4
5
 
6
7
8
9
 
10
11
12
13
0
@@ -3,11 +3,11 @@
0
     <h2>trends</h2>
0
     <div class="chart">
0
       <h4>24 hour</h4>
0
- <img src="<%= chart(@uri.last_24_hours) %>" />
0
+ <%= chart_for(@uri.last_24_hours) %>
0
     </div>
0
     <div class="chart">
0
       <h4>30 day</h4>
0
- <img src="<%= chart(@uri.last_30_days)%>" />
0
+ <%= chart_for(@uri.last_30_days)%>
0
     </div>  
0
   </div>
0
 </div>
...
1
2
3
 
4
5
6
...
95
96
97
98
 
99
100
101
...
1
2
 
3
4
5
6
...
95
96
97
 
98
99
100
101
0
@@ -1,6 +1,6 @@
0
 <html>
0
   <head>
0
- <title>clientperf <%= ": #{@page_title}" if @page_title %></title>
0
+ <title>clientperf <%= ": #{h(@page_title)}" if @page_title %></title>
0
     <style type="text/css">
0
       body {
0
         margin:0;
0
@@ -95,7 +95,7 @@
0
   <body>
0
     <div id="header">
0
       <h1><%= link_to "clientperf", :controller => 'clientperf', :action => 'index' %></h1>
0
- <%= "<h3><span>&raquo;</span>#{@uri.uri}</h3>" if @uri %>
0
+ <%= "<h3><span>&raquo;</span>#{h(@uri.uri)}</h3>" if @uri %>
0
       <div style="clear:both"></div>
0
     </div>
0
     <div id="content">

Comments

    No one has commented yet.