<commit_before><?php
$host = '***REMOVED***';
$user = '***REMOVED***';
$pwd = '***<PASSWORD>***'; 
$db = '***REMOVED***';
$conn = new mysqli($host,$user,$pwd,$db);
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}

/*This will rank the schools at the entidad level */

$entidades = range(1,32);
$niveles = array(12,13,22);
$grados = array(4,3,1);
$conn->query('UPDATE escuelas SET rank_nacional = NULL WHERE 1');
foreach($niveles as $i => $nivel){
	$grado = $grados[$i];
	$sql = "SET @rownum = 0, @rank = 0, @prev_val = NULL; ";
	$conn->query($sql);
	echo $sql.'<br/>';
	$sql = "UPDATE escuelas t1
			JOIN (
			SELECT @rownum := @rownum + 1 AS row,
			@rank := IF(@prev_val!=promedio_general,@rownum,@rank) AS rank,
			@prev_val := promedio_general AS promedio_general,
			cct
			FROM escuelas
			WHERE nivel = $nivel AND `promedio_general` IS NOT NULL AND total_evaluados >= 0 AND poco_confiables<=.1*total_evaluados AND grados >= $grado
			ORDER BY promedio_general DESC) t2
			ON t1.cct=t2.cct
			SET t1.rank_nacional=t2.rank;";
	if(!$conn->query($sql)){
		echo "Table creation failed: (" . $conn->errno . ") " . $conn->error;
	}
	echo $sql.'<br/>';
}

$conn->close();

?><commit_msg>rank natnl<commit_after><?php
$host = '***REMOVED***';
$user = '***REMOVED***';
$pwd = '***REMOVED***'; 
$db = '***REMOVED***';
$conn = new mysqli($host,$user,$pwd,$db);
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}

/*This will rank the schools at the entidad level */

$niveles = array(12,13,22);
$grados = array(4,3,1);
$conn->query('UPDATE escuelas SET rank_nacional = NULL WHERE 1');
foreach($niveles as $i => $nivel){
	$grado = $grados[$i];
	$sql = "SET @rownum = 0, @rank = 0, @prev_val = NULL; ";
	$conn->query($sql);
	echo $sql.'<br/>';
	$sql = "UPDATE escuelas t1
			JOIN (
			SELECT @rownum := @rownum + 1 AS row,
			@rank := IF(@prev_val!=promedio_general,@rownum,@rank) AS rank,
			@prev_val := promedio_general AS promedio_general,
			cct
			FROM escuelas
			WHERE nivel = '$nivel' AND `promedio_general` IS NOT NULL AND total_evaluados >= 0 AND poco_confiables<=.1*total_evaluados AND grados >= $grado
			ORDER BY promedio_general DESC) t2
			ON t1.cct=t2.cct
			SET t1.rank_nacional=t2.rank;";
	if(!$conn->query($sql)){
		echo "Table creation failed: (" . $conn->errno . ") " . $conn->error;
	}
	echo $sql.'<br/>';
}

$conn->close();

?>
{'fraction_non_alphanumeric': 0.20554649265905384, 'fraction_numerical': 0.01835236541598695, 'mean_word_length': 4.463251670378619, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 28, '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': '1022069', 'n_tokens_mistral': 1045, 'n_tokens_neox': 985, 'n_words': 229}