more stuff

This commit is contained in:
biglyderv 2025-01-30 08:20:17 -05:00
parent 543293adf2
commit 03adc50206
2 changed files with 31 additions and 17 deletions

11
rank.js
View file

@ -5,7 +5,7 @@ function rankCalc(result, iterations = 10) {
let fng = {};
let fnc = {};
let frs = {};
let msum_old = 0;
let msum_old = 0.001;
let pr = {};
for (let unn in result) {
@ -44,12 +44,15 @@ function rankCalc(result, iterations = 10) {
for (let una in result) {
pr[una] = 0;
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) {
let prb = prold[unb];
if (prb < 1 / 1e4 || fnc[unb] == 0) {
//msum += matrixe[una][unb];
if (prb < 1 / 1e9 || fnc[unb] == 0) {
matrixe[una][unb] = matrixf[una][unb];
continue;
}
matrixe[una][unb] = 0.03;

View file

@ -2,23 +2,36 @@
import { writeFile } from "fs/promises";
import { rankCalc } from "./rank.js";
(async function () {
let cache = {};
async function siteCollector(user, path) {
let users = [];
let i = 0;
while (true) {
let h1 = await fetch(`https://api.darflen.com/users/paradock/followers/${i}`)
let j1 = await h1.json();
let p = `https://api.darflen.com/users/${user}/${path}/${i}`;
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];
if (users2.length == 0) break;
i++;
console.log(`User ${user} has ${i} pages calculated`);
}
return users;
}
(async function () {
let users = await siteCollector('paradock','followers');
let data = {};
let p = [];
for (let u of users) {
@ -27,17 +40,15 @@ import { rankCalc } from "./rank.js";
p = [];
}
p.push((async function () {
let h1 = await fetch(`https://api.darflen.com/users/${u}/followers`)
let j1 = await h1.json();
let j1 = await siteCollector(u,'followers');
let h2 = await fetch(`https://api.darflen.com/users/${u}/following`)
let j2 = await h2.json();
let j2 = await siteCollector(u,'following');
data[u] = {
followers: j1.followers.map(x => x.profile.username),
following: j2.following.map(x => x.profile.username)
followers: j1,
following: j2,
}
console.log(`User ${u} calculated`);
console.log(`User ${u} fully calculated`);
})())
}