more optimization
This commit is contained in:
parent
02629be5bf
commit
14409dd748
1 changed files with 12 additions and 29 deletions
|
@ -3,12 +3,20 @@
|
|||
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 }
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue