<commit_before><!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
    <meta http-equiv="Content-type">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" href="https://code.jquery.com/ui/1.12.0/themes/base/jquery-ui.css">
    <link rel="stylesheet" type="text/css" href="/node_modules/line-chart/dist/css/line-chart.css">
    <link rel="stylesheet" type="text/css" href="/css/app.css">
    <script src="https://code.jquery.com/jquery-2.2.0.min.js"></script>
    <script src="https://d3js.org/d3.v4.min.js"></script>
    <script type="text/javascript" src="/node_modules/socket.io-client/socket.io.js"></script>
    <script type="text/javascript" src="/node_modules/line-chart/dist/line-chart.js"></script>
	<title>Live</title>
	<script type="text/javascript">

		$(document).ready(function () {
			
			var socket = io();
			socket.on('connect', function () {
				console.log('connected to server websocket')
			})
			socket.on('temp', function (realtime_data) {
				console.log(realtime_data)

				// Check to see if data is correct
				if (typeof realtime_data.temperature === 'string' && typeof realtime_data.date === 'string') {

					if (fixed) {
						data.shift();
					} 

					data.push({
						x: new Date(realtime_data.date),
						y: realtime_data.temperature
					});

					if(default_chart_loaded) {
						linechart.data([data])
						.update()
					}
				}
			})

			/*----------------------------------------------------------------------------------
			* Load default chart
			**---------------------------------------------------------------------------------*/
			
			// Select chart host element
			var selection = d3.select("div.chart")
			var data;
			var fixed = false;
			var linechart;
			var default_chart_loaded = false;

			// Data is stored at GMT on server
			// When conerted back to Date object using new Date() in browser it will be correct.
			// Always Send ISO8601 to server!

			// Default to get data from an hour ago till now
			var date_now = new Date();
			var date_old = new Date()
			date_old.setMinutes(date_now.getMinutes()-10);

			// Set data URL
			var url = '/temp/datetime?start=' + date_old.toISOString() + '&end=' + date_now.toISOString();

			// Get data for default chart
			$.getJSON(url, function (default_data) {
				// Convert date values in date objects
				// Map value to x and y
				data = default_data.rows.map(function (value) {
					return {
						x: new Date(value.date),
						y: value.temperature
					}
				})

				// Render default chart
				linechart = lineChart.chart(selection, 'temp-chart')
					.ratio(4,2)
					.data([data])
					.scaleX('time')
					.xLabel('Time')
					.axisPadding({y:1})
					.yLabel('Temperature (degrees C)')
					.title('Temperature vs Time')
					.grid(true)
					.render()

				default_chart_loaded = true;
			});

		});

	</script>
</head>
<body>
	<div class="overflow-wrapper">
		{{> nav}}
	</div>

	<div class="chart"></div>
</body>
</html><commit_msg>parse data temp to int<commit_after><!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
    <meta http-equiv="Content-type">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" href="https://code.jquery.com/ui/1.12.0/themes/base/jquery-ui.css">
    <link rel="stylesheet" type="text/css" href="/node_modules/line-chart/dist/css/line-chart.css">
    <link rel="stylesheet" type="text/css" href="/css/app.css">
    <script src="https://code.jquery.com/jquery-2.2.0.min.js"></script>
    <script src="https://d3js.org/d3.v4.min.js"></script>
    <script type="text/javascript" src="/node_modules/socket.io-client/socket.io.js"></script>
    <script type="text/javascript" src="/node_modules/line-chart/dist/line-chart.js"></script>
	<title>Live</title>
	<script type="text/javascript">

		$(document).ready(function () {
			
			var socket = io();
			socket.on('connect', function () {
				console.log('connected to server websocket')
			})
			socket.on('temp', function (realtime_data) {
				console.log(realtime_data)

				// Check to see if data is correct
				if (typeof realtime_data.temperature === 'string' && typeof realtime_data.date === 'string') {

					if (fixed) {
						data.shift();
					} 

					data.push({
						x: new Date(realtime_data.date),
						y: parseInt(realtime_data.temperature)
					});
					console.log(data)

					if(default_chart_loaded) {
						linechart.data([data])
						.update()
					}
				}
			})

			/*----------------------------------------------------------------------------------
			* Load default chart
			**---------------------------------------------------------------------------------*/
			
			// Select chart host element
			var selection = d3.select("div.chart")
			var data;
			var fixed = false;
			var linechart;
			var default_chart_loaded = false;

			// Data is stored at GMT on server
			// When conerted back to Date object using new Date() in browser it will be correct.
			// Always Send ISO8601 to server!

			// Default to get data from an hour ago till now
			var date_now = new Date();
			var date_old = new Date()
			date_old.setMinutes(date_now.getMinutes()-10);

			// Set data URL
			var url = '/temp/datetime?start=' + date_old.toISOString() + '&end=' + date_now.toISOString();

			// Get data for default chart
			$.getJSON(url, function (default_data) {
				// Convert date values in date objects
				// Map value to x and y
				data = default_data.rows.map(function (value) {
					return {
						x: new Date(value.date),
						y: parseInt(value.temperature)
					}
				})

				// Render default chart
				linechart = lineChart.chart(selection, 'temp-chart')
					.ratio(4,2)
					.data([data])
					.scaleX('time')
					.xLabel('Time')
					.axisPadding({y:1})
					.yLabel('Temperature (degrees C)')
					.title('Temperature vs Time')
					.grid(true)
					.render()

				default_chart_loaded = true;
			});

		});

	</script>
</head>
<body>
	<div class="overflow-wrapper">
		{{> nav}}
	</div>

	<div class="chart"></div>
</body>
</html>
{'fraction_non_alphanumeric': 0.21, 'fraction_numerical': 0.007213114754098361, 'mean_word_length': 2.3894444444444445, 'pattern_counts': {'":': 0, '<': 61, '<?xml version=': 0, '>': 63, 'https://': 6, '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': '1494282', 'n_tokens_mistral': 2372, 'n_tokens_neox': 1917, 'n_words': 430}