more stuff
This commit is contained in:
parent
543293adf2
commit
03adc50206
2 changed files with 31 additions and 17 deletions
11
rank.js
11
rank.js
|
@ -5,7 +5,7 @@ function rankCalc(result, iterations = 10) {
|
||||||
let fng = {};
|
let fng = {};
|
||||||
let fnc = {};
|
let fnc = {};
|
||||||
let frs = {};
|
let frs = {};
|
||||||
let msum_old = 0;
|
let msum_old = 0.001;
|
||||||
let pr = {};
|
let pr = {};
|
||||||
|
|
||||||
for (let unn in result) {
|
for (let unn in result) {
|
||||||
|
@ -44,12 +44,15 @@ function rankCalc(result, iterations = 10) {
|
||||||
for (let una in result) {
|
for (let una in result) {
|
||||||
pr[una] = 0;
|
pr[una] = 0;
|
||||||
matrixe[una] = [];
|
matrixe[una] = [];
|
||||||
if (frs[una].length == 0) continue;
|
if (frs[una].length == 0) {
|
||||||
|
matrixe[una] = structuredClone(matrixf[una]); // probably not efficient
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
for (let unb in result) {
|
for (let unb in result) {
|
||||||
let prb = prold[unb];
|
let prb = prold[unb];
|
||||||
if (prb < 1 / 1e4 || fnc[unb] == 0) {
|
if (prb < 1 / 1e9 || fnc[unb] == 0) {
|
||||||
//msum += matrixe[una][unb];
|
matrixe[una][unb] = matrixf[una][unb];
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
matrixe[una][unb] = 0.03;
|
matrixe[una][unb] = 0.03;
|
||||||
|
|
|
@ -2,23 +2,36 @@
|
||||||
import { writeFile } from "fs/promises";
|
import { writeFile } from "fs/promises";
|
||||||
import { rankCalc } from "./rank.js";
|
import { rankCalc } from "./rank.js";
|
||||||
|
|
||||||
(async function () {
|
let cache = {};
|
||||||
|
|
||||||
|
async function siteCollector(user, path) {
|
||||||
let users = [];
|
let users = [];
|
||||||
|
|
||||||
let i = 0;
|
let i = 0;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
let h1 = await fetch(`https://api.darflen.com/users/paradock/followers/${i}`)
|
let p = `https://api.darflen.com/users/${user}/${path}/${i}`;
|
||||||
let j1 = await h1.json();
|
let j1 = cache[p]
|
||||||
|
if (!j1) {
|
||||||
|
let h1 = await fetch(p);
|
||||||
|
j1 = await h1.json();
|
||||||
|
}
|
||||||
|
cache[p] = j1;
|
||||||
|
|
||||||
let users2 = j1.followers.map(x => x.profile.username);
|
let users2 = j1[path].map(x => x.profile.username);
|
||||||
|
|
||||||
users = [...users, ...users2];
|
users = [...users, ...users2];
|
||||||
|
|
||||||
if (users2.length == 0) break;
|
if (users2.length == 0) break;
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
|
console.log(`User ${user} has ${i} pages calculated`);
|
||||||
}
|
}
|
||||||
|
return users;
|
||||||
|
}
|
||||||
|
|
||||||
|
(async function () {
|
||||||
|
let users = await siteCollector('paradock','followers');
|
||||||
|
|
||||||
let data = {};
|
let data = {};
|
||||||
let p = [];
|
let p = [];
|
||||||
for (let u of users) {
|
for (let u of users) {
|
||||||
|
@ -27,17 +40,15 @@ import { rankCalc } from "./rank.js";
|
||||||
p = [];
|
p = [];
|
||||||
}
|
}
|
||||||
p.push((async function () {
|
p.push((async function () {
|
||||||
let h1 = await fetch(`https://api.darflen.com/users/${u}/followers`)
|
let j1 = await siteCollector(u,'followers');
|
||||||
let j1 = await h1.json();
|
|
||||||
|
|
||||||
let h2 = await fetch(`https://api.darflen.com/users/${u}/following`)
|
let j2 = await siteCollector(u,'following');
|
||||||
let j2 = await h2.json();
|
|
||||||
|
|
||||||
data[u] = {
|
data[u] = {
|
||||||
followers: j1.followers.map(x => x.profile.username),
|
followers: j1,
|
||||||
following: j2.following.map(x => x.profile.username)
|
following: j2,
|
||||||
}
|
}
|
||||||
console.log(`User ${u} calculated`);
|
console.log(`User ${u} fully calculated`);
|
||||||
})())
|
})())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue