Prev | Current Page 274 | Next

David Berube

"Practical Reporting with Ruby and Rails"

find(:all)
g = Gruff::Bar.new(1000)
g.title = "Cost Per Sale Report"
g.legend_font_size = 16
g.y_axis_label = 'Cost (USD)'
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 (?)
AND
path_info LIKE "/cart/checkout%"',
visitor_addresses])
total_cost = visitor_addresses.length*a.cost_per_click
cost_per_sale = total_cost / sale_count
CHAPTER 10 n CALCULATING COSTS BY ANALYZING APACHE WEB LOGS 197
g.data(a.company_name, [a.cost_per_click, cost_per_sale ] )
end
g.labels = {0 => 'Cost Per Click', 1 => 'Cost Per Sale' }
g.minimum_value = 0
g.write(graph_tempfile_name)
graph_tempfile_name
end
# These two methods will display errors as HTML, as per
# the rpdf documentation at http://railspdfplugin.rubyforge.org/wiki/wiki.pl
def rescue_action_in_public(exception)
headers.delete("Content-Disposition")
super
end
def rescue_action_locally(exception)
headers.


Pages:
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286
zarządzanie sprzedażą kwatery nad morzem międzyzdroje online loan for bad credit remont warszawa pozycjonowanie stron w google