<commit_before>google.load('visualization', '1.1', {
	'packages' : [ 'annotationchart' ]
});






function drawAnnotationChart(chart, data, options) {
	chart.draw(data, options);
}




$(function() {
	google.setOnLoadCallback(drawChart);
	
	var msChart = new google.visualization.AnnotationChart(document.getElementById('marketStatsChart'));
	var msChartData = new google.visualization.DataTable();
	msChartData.addColumn('datetime', 'Date');
	msChartData.addColumn('number', 'HITs available');
	msChartData.addColumn('number', 'HIT groups available');

	var groupsChart = new google.visualization.AnnotationChart(document.getElementById('groupsChart'));
	var groupsChartData = new google.visualization.DataTable();
	groupsChartData.addColumn('datetime', 'Date');
	groupsChartData.addColumn('number', 'HIT groups posted');

	var hitsChart = new google.visualization.AnnotationChart(document.getElementById('hitsChart'));
	var hitsChartData = new google.visualization.DataTable();
	hitsChartData.addColumn('datetime', 'Date');
	hitsChartData.addColumn('number', 'HITs posted');

	var rewardsChart = new google.visualization.AnnotationChart(document.getElementById('rewardsChart'));
	var rewardsChartData = new google.visualization.DataTable();
	rewardsChartData.addColumn('datetime', 'Date');
	rewardsChartData.addColumn('number', 'Rewards posted');
	
	$.datepicker.setDefaults($.extend({
		dateFormat : 'mm/dd/yy',
		showMonthAfterYear : false
	}));

	// datepickers
	$('#date_from').datepicker();
	$('#date_to').datepicker();

	var pastDate = new Date();
	pastDate.setDate(pastDate.getDate() - 7);

	var maxDate = new Date();
	maxDate.setDate(maxDate.getDate() + 1);

	$('#date_from').datepicker('setDate', pastDate);
	$('#date_to').datepicker('setDate', new Date());
	$('#date_from').datepicker('option', 'maxDate', maxDate);
	$('#date_to').datepicker('option', 'maxDate', maxDate);


	$('#date_from').on('change', function() {
		fillArrivalData(host, protocol);
		
		drawChart();
	});

	$('#date_to').on('change', function() {
		fillArrivalData(host, protocol);
		
		drawChart();
	});
	
	var activeTab = '#marketStats';

	// charts
	var options = {
		displayAnnotations : true,
		scaleType : 'allmaximized',
		scaleColumns : [ 0, 1 ]
	};
	
	$('#chartsTab a').click(function(e) {
		e.preventDefault();
		$(this).tab('show');
		activeTab = $(this).attr('href');

		drawChart();
	});


	
	var host = window.location.host;
	var protocol = host.indexOf('localhost', 0) == 0 ? 'http' : 'https';
	fillArrivalData(host, protocol);
	
	drawChart();
	
	function fillArrivalData(host, protocol) {
		var url = protocol + '://' + host + '/_ah/api/mturk/v1/arrivalCompletions/list?from=' + $("#date_from").val() + '&to=' + $("#date_to").val();

		$.ajax({type : 'GET',  url : url, dataType : 'json'})
			.done(function(response) {
				if (response.items) {
					$.each(response.items, function(index, item) {
						msChartData.addRows([ [new Date(item.from), item.hitsAvailableUI,	item.hitGroupsAvailableUI ] ]);	
						groupsChartData.addRows([ [ new Date(item.from), parseInt(item.hitGroupsArrived) ] ]);
						hitsChartData.addRows([ [ new Date(item.from),	parseInt(item.hitsArrived) ] ]);
						rewardsChartData.addRows([ [ new Date(item.from), parseInt(item.rewardsArrived) / 100 ] ]);
					});
				}
			})
			.fail(function(e) {
			})
			.complete(function(e) {
				drawChart();
			})
			;
	}
	
	function drawChart() {

		if (activeTab == '#marketStats') {
			drawAnnotationChart(msChart, msChartData, options);
		} else if (activeTab == '#hits') {
			drawAnnotationChart(hitsChart, hitsChartData, options);
		} else if (activeTab == '#rewards') {
			drawAnnotationChart(rewardsChart, rewardsChartData, options);
		} else if (activeTab == '#groups') {
			drawAnnotationChart(groupsChart, groupsChartData, options);
		}

	}


});

<commit_msg>Fixing a couple of UI bugs<commit_after>google.load('visualization', '1.1', {
	'packages' : [ 'annotationchart' ]
});






function drawAnnotationChart(chart, data, options) {
	chart.draw(data, options);
}




$(function() {
	

	
	google.setOnLoadCallback(drawChart);
	
	var msChart;
	var msChartData;
	
	var groupsChart;
	var groupsChartData;

	var hitsChart;
	var hitsChartData;

	var rewardsChart;
	var rewardsChartData;
	
	 init();
	
	$.datepicker.setDefaults($.extend({
		dateFormat : 'mm/dd/yy',
		showMonthAfterYear : false
	}));

	// datepickers
	$('#date_from').datepicker();
	$('#date_to').datepicker();

	var pastDate = new Date();
	pastDate.setDate(pastDate.getDate() - 7);

	var maxDate = new Date();
	maxDate.setDate(maxDate.getDate() + 1);

	$('#date_from').datepicker('setDate', pastDate);
	$('#date_to').datepicker('setDate', new Date());
	$('#date_from').datepicker('option', 'maxDate', maxDate);
	$('#date_to').datepicker('option', 'maxDate', maxDate);


	$('#date_from').on('change', function() {
		init();
		fillArrivalData(host, protocol);
		drawChart();
	});

	$('#date_to').on('change', function() {
		init();
		fillArrivalData(host, protocol);
		drawChart();
	});
	
	var activeTab = '#marketStats';

	// charts
	var options = {
		displayAnnotations : true,
		scaleType : 'allmaximized',
		scaleColumns : [ 0, 1 ]
	};
	
	$('#chartsTab a').click(function(e) {
		e.preventDefault();
		$(this).tab('show');
		activeTab = $(this).attr('href');
		drawChart();
	});


	
	var host = window.location.host;
	var protocol = host.indexOf('localhost', 0) == 0 ? 'http' : 'https';
	fillArrivalData(host, protocol);
	
	drawChart();
	
	function fillArrivalData(host, protocol) {
		var url = protocol + '://' + host + '/_ah/api/mturk/v1/arrivalCompletions/list?from=' + $("#date_from").val() + '&to=' + $("#date_to").val();

		$.ajax({type : 'GET',  url : url, dataType : 'json'})
			.done(function(response) {
				if (response.items) {
					$.each(response.items, function(index, item) {
						msChartData.addRows([ [new Date(item.from), item.hitsAvailableUI,	item.hitGroupsAvailableUI ] ]);	
						groupsChartData.addRows([ [ new Date(item.from), parseInt(item.hitGroupsArrived) ] ]);
						hitsChartData.addRows([ [ new Date(item.from),	parseInt(item.hitsArrived) ] ]);
						rewardsChartData.addRows([ [ new Date(item.from), parseInt(item.rewardsArrived) / 100 ] ]);
					});
				}
			})
			.fail(function(e) {
			})
			.complete(function(e) {
				drawChart();
			})
			;
	}
	
	function drawChart() {

		if (activeTab == '#marketStats') {
			drawAnnotationChart(msChart, msChartData, options);
		} else if (activeTab == '#hits') {
			drawAnnotationChart(hitsChart, hitsChartData, options);
		} else if (activeTab == '#rewards') {
			drawAnnotationChart(rewardsChart, rewardsChartData, options);
		} else if (activeTab == '#groups') {
			drawAnnotationChart(groupsChart, groupsChartData, options);
		}

	}
	function init() {
		if (!msChart) msChart = new google.visualization.AnnotationChart(document.getElementById('marketStatsChart'));
		msChartData = new google.visualization.DataTable();
		msChartData.addColumn('datetime', 'Date');
		msChartData.addColumn('number', 'HITs available');
		msChartData.addColumn('number', 'HIT groups available');

		if (!groupsChart) groupsChart = new google.visualization.AnnotationChart(document.getElementById('groupsChart'));
		groupsChartData = new google.visualization.DataTable();
		groupsChartData.addColumn('datetime', 'Date');
		groupsChartData.addColumn('number', 'HIT groups posted');

		if (!hitsChart) hitsChart = new google.visualization.AnnotationChart(document.getElementById('hitsChart'));
		hitsChartData = new google.visualization.DataTable();
		hitsChartData.addColumn('datetime', 'Date');
		hitsChartData.addColumn('number', 'HITs posted');

		if (!rewardsChart) rewardsChart = new google.visualization.AnnotationChart(document.getElementById('rewardsChart'));
		rewardsChartData = new google.visualization.DataTable();
		rewardsChartData.addColumn('datetime', 'Date');
		rewardsChartData.addColumn('number', 'Rewards posted');
	}

});


{'fraction_non_alphanumeric': 0.1763595166163142, 'fraction_numerical': 0.0030211480362537764, 'mean_word_length': 4.996226415094339, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3802360', 'n_tokens_mistral': 2852, 'n_tokens_neox': 2536, 'n_words': 458}