write(graph_tempfile_name)
graph_tempfile_name
end
This function uses Gruff (introduced in Chapter 3) to generate the graph. The function
sets various parameters relating to the graph, and then loops through all of the
advertisers. For each advertiser, it finds all of the visitors, as defined by visitors who arrive
at the site by clicking a link on the referrer URL. It then finds all of the sale URLs for those
visitors, which are defined as URLs that start with /cart/checkout. Note that if visitors
check out multiple times, they will be counted as multiple sales, and if they click the
referrer link more than once, that will be counted as multiple visits.
Then the company name of each advertiser, along with the total number of visitors
and the number of visitors who have purchased something, is graphed, and the graph is
written to the temporary file name created by the get_tempfile_name function. The temporary
file name is returned, so that the calling function can use the graph.
Next, let??™s take a look at the get_sale_graph_tempfile function in the report controller:
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:
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304