fix threshold logic
This commit is contained in:
parent
8531c671f4
commit
03b7527839
1 changed files with 16 additions and 15 deletions
19
site.js
19
site.js
|
@ -80,7 +80,7 @@ async function urlCollector(url, path, file, useLimit, data2) {
|
||||||
if (!data2[url]) data2[url] = { following: [], followers: [] };
|
if (!data2[url]) data2[url] = { following: [], followers: [] };
|
||||||
data2[url][path] = [...new Set(urls)];
|
data2[url][path] = [...new Set(urls)];
|
||||||
|
|
||||||
data2[url][path].sort((x,y) => ((new URL(x).host == new URL(url).host) ? 1 : 0) - ((new URL(y).host == new URL(url).host) ? 1 : 0))
|
data2[url][path].sort((x, y) => ((new URL(x).host == new URL(url).host) ? 1 : 0) - ((new URL(y).host == new URL(url).host) ? 1 : 0))
|
||||||
|
|
||||||
return data2[url][path];
|
return data2[url][path];
|
||||||
}
|
}
|
||||||
|
@ -153,7 +153,7 @@ async function rounder(users, data, mode) {
|
||||||
let oldLength = endn.length;
|
let oldLength = endn.length;
|
||||||
for (let h in data) {
|
for (let h in data) {
|
||||||
endn.push(h);
|
endn.push(h);
|
||||||
if (endn.length > oldLength * 1.25 ) {
|
if (endn.length > oldLength * 1.25) {
|
||||||
endn = [...new Set(endn)];
|
endn = [...new Set(endn)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -260,18 +260,19 @@ async function siteCollector(user, path, site, useLimit, data2) {
|
||||||
for (let i = 0; i < d; i++) {
|
for (let i = 0; i < d; i++) {
|
||||||
if (i != 0) {
|
if (i != 0) {
|
||||||
let tempSet = dat.map(x => x[0]);
|
let tempSet = dat.map(x => x[0]);
|
||||||
users = tempSet.concat(await rounder(tempSet, data, true));
|
let oldLength = Object.keys(data).length;
|
||||||
|
let theData = {};
|
||||||
|
for (let a = 0; a < oldLength * threshold && a < oldLength; a++) {
|
||||||
|
let key = Object.keys(data)[a];
|
||||||
|
theData[key] = data[key];
|
||||||
|
}
|
||||||
|
users = tempSet.concat(await rounder(tempSet, theData, true));
|
||||||
users = [...new Set(users)];
|
users = [...new Set(users)];
|
||||||
}
|
}
|
||||||
let oldLength = Object.keys(data).length;
|
|
||||||
for (let uf of users) {
|
for (let uf of users) {
|
||||||
if (Object.keys(data).length > oldLength * threshold) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
let u = data[uf];
|
let u = data[uf];
|
||||||
if (!u) {
|
if (!u) {
|
||||||
data[uf] = {following: [], followers: []}
|
data[uf] = { following: [], followers: [] }
|
||||||
}
|
}
|
||||||
let { following, followers } = u;
|
let { following, followers } = u;
|
||||||
if (!following || !followers) continue;
|
if (!following || !followers) continue;
|
||||||
|
|
Loading…
Reference in a new issue