Prev | Current Page 273 | Next

David Berube

"Practical Reporting with Ruby and Rails"

join(RAILS_ROOT, "tmp/#{prefix}_#{request.env['REMOTE_ADDR']
}_#{Time.now.to_f
}_#{rand(10000)}.jpg")
end
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 }
sale_count = Hit.count('remote_addr',
:conditions=>['remote_addr IN (?)
CHAPTER 10 n CALCULATING COSTS BY ANALYZING APACHE WEB LOGS 196
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.write(graph_tempfile_name)
graph_tempfile_name
end
def get_sale_graph_tempfile # Graph of per-click and per-sale costs
graph_tempfile_name = get_tempfile_name('sale_graph_tempfile')
advertisers = Advertiser.


Pages:
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285
MBrother wyniki na żywo Mary Mary Little Eva prace magisterskie