<commit_before><?php
require_once "sql_functions.php";
require_once "update.php";


function updateIfNecessary()
{
	$now = time();
	$lastUpdate = strtotime(sqlQuery("SELECT * FROM UpdateLog ORDER BY updatedatetime DESC LIMIT 1")[0]['updatedatetime']);

	if (!$lastUpdate || ($now - $lastUpdate) >= 21600) // Update when it's been >= 6 hours since the last update.
	{
		error_log("Update is necessary.  Updating...");
		update_with_api();
	}
}

// Check if the cached file is still fresh. If it is, serve it up and exit.
if (file_exists("cache_index.html"))
{
	error_log("Cache file found. Redirecting...");
	header("Location: /cache_index.html", true, 302);

	// Close the connection (http://www.php.net/manual/en/features.connection-handling.php#71172)
	error_log("Closing connection");
	ob_end_clean();
	header("Connection: close");
	ignore_user_abort(true); // just to be safe
	ob_start();
	$size = ob_get_length();
	header("Content-Length: $size");
	ob_end_flush(); // Strange behaviour, will not work
	flush(); // Unless both are called !
	
	updateIfNecessary();
	sleep(30);
	
	exit();
}

ob_start();<commit_msg>Removed delay.  Re-testing with Heroku.<commit_after><?php
require_once "sql_functions.php";
require_once "update.php";


function updateIfNecessary()
{
	$now = time();
	$lastUpdate = strtotime(sqlQuery("SELECT * FROM UpdateLog ORDER BY updatedatetime DESC LIMIT 1")[0]['updatedatetime']);

	if (!$lastUpdate || ($now - $lastUpdate) >= 21600) // Update when it's been >= 6 hours since the last update.
	{
		error_log("Update is necessary.  Updating...");
		update_with_api();
	}
}

// Check if the cached file is still fresh. If it is, serve it up and exit.
if (file_exists("cache_index.html"))
{
	error_log("Cache file found. Redirecting...");
	header("Location: /cache_index.html", true, 302);

	// Close the connection (http://www.php.net/manual/en/features.connection-handling.php#71172)
	error_log("Closing connection");
	ob_end_clean();
	header("Connection: close");
	ignore_user_abort(true); // just to be safe
	ob_start();
	$size = ob_get_length();
	header("Content-Length: $size");
	ob_end_flush(); // Strange behaviour, will not work
	flush(); // Unless both are called !
	
	updateIfNecessary();
	
	exit();
}

ob_start();
{'fraction_non_alphanumeric': 0.1592526690391459, 'fraction_numerical': 0.015124555160142349, 'mean_word_length': 4.6936708860759495, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2292584', 'n_tokens_mistral': 790, 'n_tokens_neox': 740, 'n_words': 200}