<commit_before><script type="text/javascript" language="text/javascript">
function changeTimeFrame(range)
{
    var mapObject = $('#world-map').vectorMap('get', 'mapObject');
    switch(range)
    {
    <% Rack::RedisAnalytics.time_range_formats.each do |range, unit, time_format| %>
    case '<%=range%>':
	setSessionCookie("_rarng", "<%=range%>");
	
	// both time range graphs powered by time range data
	$.ajax({
	    url: '<%=Rack::RedisAnalytics.api_endpoint + "/data?p=unique_visits,first_visits,repeat_visits&unit_count=#{(1.send(range)/1.send(unit)).round}&unit=#{unit}"%>',
	    dataType: "json",
	    success: function(data) {
		visits_area.setData(data);
		unique_visits_line.setData(data);
	    }
	});

	// aggregate data powers the 3 donuts
	$.ajax({
	    url: '<%=Rack::RedisAnalytics.api_endpoint + "/data?p=first_visits,repeat_visits,browser,referrer,page_views,second_page_views,visit_time,recency&unit_count=#{(1.send(range)/1.send(unit)).round}&unit=#{unit}&aggregate=yes"%>',
	    dataType: "json",
	    success: function(data) {

		// parse visits data from json
		var visits_json_data = []
		var first_visits = data[0].first_visits;
		var repeat_visits = data[1].repeat_visits;
		var total_visits = first_visits + repeat_visits;
		var page_views = data[4].page_views;
		var second_page_views = data[5].second_page_views;
		var page_depth = Math.round(page_views/total_visits);
		var bounce_rate = Math.round(((total_visits - second_page_views)/total_visits) * 100);
		var percent_first_visits = Math.round((first_visits / total_visits) * 100);
		var total_visit_time = data[6].visit_time;
		var avg_visit_time = Math.round((total_visit_time / total_visits));
		var total_recency = data[7].recency;

		visits_json_data.push({'label': 'first_visits', 'value': first_visits});
		visits_json_data.push({'label': 'repeat_visits', 'value': repeat_visits});
		visits_donut = Morris.Donut({element: 'visits_donut', data: visits_json_data});
		$("#total_visits")[0].innerHTML = total_visits + ' <small class="muted">visits</small>';
		$("#total_page_views")[0].innerHTML = page_views + ' <small class="muted">page views</small>';
		$("#page_depth")[0].innerHTML = page_depth + ' <small class="muted">pages per visit</small>';		
		$("#bounce_rate")[0].innerHTML = bounce_rate + '% <small class="muted">bounce rate</small>';
		$("#visit_duration")[0].innerHTML = avg_visit_time + ' sec <small class="muted">avg time spent</small>';
		$("#first_visits")[0].innerHTML = percent_first_visits + '% <small class="muted">new visits</small></h4>';

		// parse browser data from json
		var browsers_json_data = [];
		for(var i in data[2].browser)
		{
		    var browser_data = {}
		    browser_data[i] = data[2].browser[i];
		    browser_data['label'] = i;<commit_msg>added decimal (2 places) for some params<commit_after><script type="text/javascript" language="text/javascript">
function changeTimeFrame(range)
{
    var mapObject = $('#world-map').vectorMap('get', 'mapObject');
    switch(range)
    {
    <% Rack::RedisAnalytics.time_range_formats.each do |range, unit, time_format| %>
    case '<%=range%>':
	setSessionCookie("_rarng", "<%=range%>");
	
	// both time range graphs powered by time range data
	$.ajax({
	    url: '<%=Rack::RedisAnalytics.api_endpoint + "/data?p=unique_visits,first_visits,repeat_visits&unit_count=#{(1.send(range)/1.send(unit)).round}&unit=#{unit}"%>',
	    dataType: "json",
	    success: function(data) {
		visits_area.setData(data);
		unique_visits_line.setData(data);
	    }
	});

	// aggregate data powers the 3 donuts
	$.ajax({
	    url: '<%=Rack::RedisAnalytics.api_endpoint + "/data?p=first_visits,repeat_visits,browser,referrer,page_views,second_page_views,visit_time,recency&unit_count=#{(1.send(range)/1.send(unit)).round}&unit=#{unit}&aggregate=yes"%>',
	    dataType: "json",
	    success: function(data) {

		// parse visits data from json
		var visits_json_data = []
		var first_visits = data[0].first_visits;
		var repeat_visits = data[1].repeat_visits;
		var total_visits = first_visits + repeat_visits;
		var page_views = data[4].page_views;
		var second_page_views = data[5].second_page_views;
		var page_depth = (page_views/total_visits).toFixed(2);
		var bounce_rate = (((total_visits - second_page_views)/total_visits) * 100).toFixed(2);
		var percent_first_visits = ((first_visits / total_visits) * 100).toFixed(2);
		var total_visit_time = data[6].visit_time;
		var avg_visit_time = ((total_visit_time / total_visits)).toFixed(2);
		var total_recency = data[7].recency;

		visits_json_data.push({'label': 'first_visits', 'value': first_visits});
		visits_json_data.push({'label': 'repeat_visits', 'value': repeat_visits});
		visits_donut = Morris.Donut({element: 'visits_donut', data: visits_json_data});
		$("#total_visits")[0].innerHTML = total_visits + ' <small class="muted">visits</small>';
		$("#total_page_views")[0].innerHTML = page_views + ' <small class="muted">page views</small>';
		$("#page_depth")[0].innerHTML = page_depth + ' <small class="muted">pages per visit</small>';		
		$("#bounce_rate")[0].innerHTML = bounce_rate + '% <small class="muted">bounce rate</small>';
		$("#visit_duration")[0].innerHTML = avg_visit_time + ' sec <small class="muted">avg time spent</small>';
		$("#first_visits")[0].innerHTML = percent_first_visits + '% <small class="muted">new visits</small></h4>';

		// parse browser data from json
		var browsers_json_data = [];
		for(var i in data[2].browser)
		{
		    var browser_data = {}
		    browser_data[i] = data[2].browser[i];
		    browser_data['label'] = i;
{'fraction_non_alphanumeric': 0.17339795368874528, 'fraction_numerical': 0.010231556273559504, 'mean_word_length': 5.501750291715286, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1881740', 'n_tokens_mistral': 2051, 'n_tokens_neox': 1935, 'n_words': 325}