diff --git a/docs/stats.php b/docs/stats.php index 6a711b9..ed70cb1 100755 --- a/docs/stats.php +++ b/docs/stats.php @@ -14,7 +14,8 @@ $pr = array(); $fcount = array(); - + $frs = array(); + foreach ($result as $usern) { $fn = $usern['username']; @@ -24,15 +25,18 @@ $stmt->execute([$fn,$fn]); $fcount[$fn] = count($stmt->fetchAll(PDO::FETCH_DEFAULT)); + + $stmt = $db->prepare("SELECT * FROM main.follow WHERE username = ?"); + $stmt->execute([$fn]); + + $frs[$fn] = $stmt->fetchAll(PDO::FETCH_DEFAULT); } - for ($i = 0; $i < 50; $i++) { + for ($i = 0; $i < 20; $i++) { foreach ($result as $usern) { $theuser = $usern['username']; - $stmt = $db->prepare("SELECT * FROM main.follow WHERE username = ?"); - $stmt->execute([$theuser]); - $followers = $stmt->fetchAll(PDO::FETCH_DEFAULT); + $followers = $frs[$theuser]; foreach ($followers as $follown) { $fn = $follown['target']; @@ -45,7 +49,7 @@ } } - $dist = 1 - ($i / 50); + $dist = 1 - ($i / 20); $dist = pow($dist,0.3); $new_sum = array_sum($pr);