stupid optimization
This commit is contained in:
parent
31b15b75d8
commit
0306a17ea3
1 changed files with 10 additions and 5 deletions
|
@ -13,9 +13,17 @@
|
|||
$result = $stmt->fetchAll(PDO::FETCH_DEFAULT);
|
||||
|
||||
$pr = array();
|
||||
$fcount = array();
|
||||
|
||||
foreach ($result as $usern) {
|
||||
$pr[$usern['username']] = 1;
|
||||
$fn = $usern['username'];
|
||||
|
||||
$pr[$fn] = 1;
|
||||
|
||||
$stmt = $db->prepare("SELECT * FROM main.follow WHERE target = ? AND NOT username = ?");
|
||||
$stmt->execute([$fn,$fn]);
|
||||
|
||||
$fcount[$fn] = count($stmt->fetchAll(PDO::FETCH_DEFAULT));
|
||||
}
|
||||
|
||||
for ($i = 0; $i < 50; $i++) {
|
||||
|
@ -31,10 +39,7 @@
|
|||
|
||||
if ($usern['username'] == $fn) continue;
|
||||
|
||||
$stmt = $db->prepare("SELECT * FROM main.follow WHERE target = ? AND NOT username = ?");
|
||||
$stmt->execute([$fn,$fn]);
|
||||
|
||||
$dst = count($stmt->fetchAll(PDO::FETCH_DEFAULT));
|
||||
$dst = $fcount[$fn];
|
||||
|
||||
$pr[$usern['username']] += $pr[$fn] / ($dst + 10) / 10;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue