more optimization

This commit is contained in:
biglyderv 2025-01-29 00:18:30 -05:00
parent 02629be5bf
commit 14409dd748

View file

@ -2,13 +2,21 @@
require(__DIR__ . "/../libs/page.php");
require(__DIR__ . "/../libs/form.php");
require(__DIR__ . "/../libs/comment.php");
function cmp($a, $b) {
if ($a == $b) {
return 0;
}
return ($a > $b) ? -1 : 1;
}
page_header();
function get_handler() {
global $db;
// this does a ton of weird matrix math
global $db;
$stmt = $db->prepare("SELECT * FROM main.auth"); //weirdly, this requires a schema name
$stmt = $db->prepare("SELECT * FROM main.auth");
$stmt->execute([]);
$result = $stmt->fetchAll(PDO::FETCH_DEFAULT);
@ -55,27 +63,14 @@
$dst = $fcount[$fn];
$msum_old += $matrixe[$usern['username']][$fn] = 1 + 1 / ($dst + 10) / 10;
///$pr[$usern['username']] += $pr[$fn] / ($dst + 10) / 10;
}
}
for ($i = 0; $i < 10; $i++) {
$prold = $pr;
$matrixf = $matrixe;
$msum = 0;
foreach ($result as $usera) {
$una = $usera['username'];
if (count($frs[$una]) == 0) continue;
foreach ($result as $userb) {
$unb = $userb['username'];
$prb = $prold[$unb];
if ($prb < 1 /1e6) {
continue;
}
}
}
foreach ($result as $usera) {
$una = $usera['username'];
$pr[$una] = 0.1;
@ -116,18 +111,6 @@
}
}
$new_sum = array_sum($pr);
foreach ($result as $usern) {
$pr[$usern['username']] = $pr[$usern['username']] * 100 / $new_sum;
}
function cmp($a, $b) {
if ($a == $b) {
return 0;
}
return ($a > $b) ? -1 : 1;
}
uasort($pr,'cmp');
foreach ($pr as $usern => $rr) { ?>
@ -143,7 +126,7 @@
</div>
</div>
</div>
<div><b>Power</b>: <?php echo $rr ?>%</div>
<div><b>Power</b>: <?php echo $rr * 100 ?>%</div>
</div>
<?php }
}