Prev | Current Page 291 | Next

David Berube

"Practical Reporting with Ruby and Rails"

In situations
where collisions are likely, you can look at a solution like the ruby-stemp library, which you can get
from http://ruby-stemp.rubyforge.org/.
Next, let??™s take a look at the function in the report controller that shows the graph of
visitors from each advertiser:
def get_visitor_graph_tempfile # Graph of visitor and purchasing visitors
graph_tempfile_name = get_tempfile_name('visitor_graph')
advertisers = Advertiser.find(:all)
g = Gruff::Bar.new(1000)
g.title = "Advertising Traffic Report"
g.legend_font_size = 16
advertisers.each do |a|
visitor_addresses = Hit.find(:all,
:group=>'remote_addr',
:conditions=>['http_referrer= ? ',
a.referrer_url]
).map { |h| h.remote_addr }
CHAPTER 10 n CALCULATING COSTS BY ANALYZING APACHE WEB LOGS 210
sale_count = Hit.count('remote_addr',
:conditions=>['remote_addr IN (?)
AND
path_info LIKE "/cart/checkout%"',
visitor_addresses])
g.data(a.company_name, [ visitor_addresses.length, sale_count ] )
end
g.labels = {0 => 'Visitors', 1 => 'Visitors With One or More Purchases' }
g.


Pages:
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303
swiat hotele londyn stolarka aluminiowa częstochowa ranking przeglądarek zakłady bukmacherskie